質問編集履歴
76
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,20 +1,6 @@
|
|
1
1
|
javascriptとreact、material-uiを用いて、アプリ作成しています。
|
2
2
|
|
3
3
|
---
|
4
|
-
|
5
|
-
- 搭載したい機能リスト
|
6
|
-
|
7
|
-
・ユーザー認証(とりあえずは完成。)
|
8
|
-
|
9
|
-
ーー(ページごとにユーザーのみ、ゲストのみと分けたい。)
|
10
|
-
|
11
|
-
進行中→●ゲスト、ユーザーが見れるプラットホーム。(ほぼ完成。これから投稿の時間等も管理したいと思います。)
|
12
|
-
|
13
|
-
ーー(ユーザーが投稿した内容が時系列で表示)
|
14
|
-
|
15
|
-
・ユーザー課金、ゲスト課金とかも導入したい。
|
16
|
-
|
17
|
-
|
18
4
|
|
19
5
|
現在のプロジェクトは[こちら。](http://plzdonation-56b64.firebaseapp.com)
|
20
6
|
|
@@ -26,337 +12,21 @@
|
|
26
12
|
|
27
13
|
|
28
14
|
|
29
|
-
|
15
|
+
課題点(要素の多さによる遅延の軽減)
|
30
16
|
|
31
17
|
---
|
32
18
|
|
19
|
+
|
20
|
+
|
33
|
-
|
21
|
+
現在、componentDidMountにて、たくさんのfetchや処理が混雑していて、遅延によりページが表示できないことが増えてきました。
|
34
22
|
|
35
23
|
|
36
24
|
|
37
|
-
ルール
|
38
|
-
|
39
|
-
```JSON
|
40
|
-
|
41
|
-
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
"rules": {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
".read": true,
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
"users": {
|
54
|
-
|
55
|
-
".read": true,
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
"$uid": {
|
60
|
-
|
61
|
-
".validate": "newData.hasChildren(['explain','profile_image','title','uid','user','userStar'])",
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
"user":{
|
66
|
-
|
67
|
-
".write": "$uid === auth.uid",
|
68
|
-
|
69
|
-
".validate": "newData.isString() && newData.val().length <= 15",
|
70
|
-
|
71
|
-
},
|
72
|
-
|
73
|
-
"uid":{
|
74
|
-
|
75
|
-
".write": "$uid === auth.uid",
|
76
|
-
|
77
|
-
".validate": "newData.isString() && newData.val() == auth.uid",
|
78
|
-
|
79
|
-
},
|
80
|
-
|
81
|
-
"explain":{
|
82
|
-
|
83
|
-
".write": "$uid === auth.uid",
|
84
|
-
|
85
|
-
".validate": "newData.isString() && newData.val().length <= 300",
|
86
|
-
|
87
|
-
},
|
88
|
-
|
89
|
-
"title":{
|
90
|
-
|
91
|
-
".write": "$uid === auth.uid",
|
92
|
-
|
93
|
-
".validate": "newData.isString() && newData.val().length <= 20",
|
94
|
-
|
95
|
-
},
|
96
|
-
|
97
|
-
"profile_image":{
|
98
|
-
|
99
|
-
".write": "$uid === auth.uid",
|
100
|
-
|
101
|
-
".validate": "newData.isString() && newData.val().matches(/^(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*((0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\+&=%\$#_]*)?$/)"
|
102
|
-
|
103
|
-
},
|
104
|
-
|
105
|
-
"user_posts":{
|
106
|
-
|
107
|
-
"$postsId":{
|
108
|
-
|
109
|
-
".write": "$uid === auth.uid",
|
110
|
-
|
111
|
-
".validate":"newData.val() === true"
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
},
|
116
|
-
|
117
|
-
"starred_users":{
|
118
|
-
|
119
|
-
"$starredUid":{
|
120
|
-
|
121
|
-
".write": "$uid === auth.uid",
|
122
|
-
|
123
|
-
".validate":"newData.val() === true",
|
124
|
-
|
125
|
-
},
|
126
|
-
|
127
|
-
},
|
128
|
-
|
129
|
-
"userStar":{
|
130
|
-
|
131
|
-
".validate":"newData.hasChild('starCount')",
|
132
|
-
|
133
|
-
"stars":{
|
134
|
-
|
135
|
-
"$starUid":{
|
136
|
-
|
137
|
-
".write":"auth.uid == $starUid &&
|
138
|
-
|
139
|
-
(!data.exists() && newData.exists() &&
|
140
|
-
|
141
|
-
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() + 1
|
142
|
-
|
143
|
-
) ||
|
144
|
-
|
145
|
-
(data.exists() && !newData.exists() &&
|
146
|
-
|
147
|
-
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() - 1
|
148
|
-
|
149
|
-
|
25
|
+
これを解消したいです。
|
150
|
-
|
151
|
-
".validate": "newData.val() == true"
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
},
|
158
|
-
|
159
|
-
"starCount":{
|
160
|
-
|
161
|
-
".write":"auth != null",
|
162
|
-
|
163
|
-
".validate":"(newData.val() == data.val() + 1 &&
|
164
|
-
|
165
|
-
newData.parent().child('stars').child(auth.uid).val() == true &&
|
166
|
-
|
167
|
-
!data.parent().child('stars').child(auth.uid).exists()
|
168
|
-
|
169
|
-
) ||
|
170
|
-
|
171
|
-
(newData.val() == data.val() - 1 &&
|
172
|
-
|
173
|
-
!newData.parent().child('stars').child(auth.uid).exists() &&
|
174
|
-
|
175
|
-
data.parent().child('stars').child(auth.uid).val() == true
|
176
|
-
|
177
|
-
)"
|
178
|
-
|
179
|
-
},
|
180
|
-
|
181
|
-
"$others":{
|
182
|
-
|
183
|
-
".validate":false
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
}
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
}
|
192
|
-
|
193
|
-
},
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
"posts":{
|
198
|
-
|
199
|
-
".read": true,
|
200
|
-
|
201
|
-
".write":"auth != null",
|
202
|
-
|
203
|
-
"$post":{
|
204
|
-
|
205
|
-
".write": "data.exists() ? (newData.child('uid').val() === auth.uid &&
|
206
|
-
|
207
|
-
newData.child('uid').val() === data.child('uid').val()) :
|
208
|
-
|
209
|
-
newData.child('uid').val() === auth.uid",
|
210
|
-
|
211
|
-
".validate":"newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp'])",
|
212
26
|
|
213
27
|
|
214
28
|
|
215
|
-
|
216
|
-
|
217
|
-
"author":{
|
218
|
-
|
219
|
-
".write":"newData.parent().child('uid').val() === auth.uid",
|
220
|
-
|
221
|
-
".validate": "newData.isString() && newData.val().length <= 15",
|
222
|
-
|
223
|
-
},
|
224
|
-
|
225
|
-
"title":{
|
226
|
-
|
227
|
-
".write":"newData.parent().child('uid').val() === auth.uid",
|
228
|
-
|
229
|
-
".validate": "newData.isString() && newData.val().length <= 20",
|
230
|
-
|
231
|
-
},
|
232
|
-
|
233
|
-
"body":{
|
234
|
-
|
235
|
-
".write":"newData.parent().child('uid').val() === auth.uid",
|
236
|
-
|
237
|
-
".validate": "newData.isString() && newData.val().length <= 300",
|
238
|
-
|
239
|
-
},
|
240
|
-
|
241
|
-
|
29
|
+
どのように復活させられるでしょう?
|
242
|
-
|
243
|
-
".write":"newData.val() === auth.uid",
|
244
|
-
|
245
|
-
},
|
246
|
-
|
247
|
-
"timestamp":{
|
248
|
-
|
249
|
-
".write":"newData.parent().child('uid').val() === auth.uid",
|
250
|
-
|
251
|
-
},
|
252
|
-
|
253
|
-
"postComment":{
|
254
|
-
|
255
|
-
".validate": "newData.hasChild('commentCount')",
|
256
|
-
|
257
|
-
".write":true,
|
258
|
-
|
259
|
-
"commentCount":{
|
260
|
-
|
261
|
-
".write":"auth != null",
|
262
|
-
|
263
|
-
".validate":"newData.isNumber()"
|
264
|
-
|
265
|
-
},
|
266
|
-
|
267
|
-
"comments":{
|
268
|
-
|
269
|
-
"$commentId":{
|
270
|
-
|
271
|
-
".write":"auth != null &&
|
272
|
-
|
273
|
-
((!data.exists() && newData.exists() &&
|
274
|
-
|
275
|
-
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() + 1
|
276
|
-
|
277
|
-
) ||
|
278
|
-
|
279
|
-
(data.exists() && !newData.exists() &&
|
280
|
-
|
281
|
-
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() - 1
|
282
|
-
|
283
|
-
))",
|
284
|
-
|
285
|
-
".validate": "newData.val() == true"
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
},
|
290
|
-
|
291
|
-
"$others": {
|
292
|
-
|
293
|
-
".write": false
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
},
|
298
|
-
|
299
|
-
"postId":{
|
300
|
-
|
301
|
-
".write": "$post === newData.val()",
|
302
|
-
|
303
|
-
},
|
304
|
-
|
305
|
-
"postStar":{
|
306
|
-
|
307
|
-
".write": "newData.val() === data.val() + 1",
|
308
|
-
|
309
|
-
},
|
310
|
-
|
311
|
-
},
|
312
|
-
|
313
|
-
},
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
"comments":{
|
318
|
-
|
319
|
-
".read": true,
|
320
|
-
|
321
|
-
".write":true,
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
"$comment":{
|
326
|
-
|
327
|
-
".write": "newData.child('uid').val() === auth.uid",
|
328
|
-
|
329
|
-
".validate": "newData.hasChildren(['author','body','commentId','uid','profile_image'])",
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
}
|
334
|
-
|
335
|
-
},
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
"$others": {
|
342
|
-
|
343
|
-
".validate": false
|
344
|
-
|
345
|
-
}
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
```
|
360
30
|
|
361
31
|
|
362
32
|
|
@@ -366,29 +36,13 @@
|
|
366
36
|
|
367
37
|
|
368
38
|
|
369
|
-
今後
|
39
|
+
<今後実装したいが搭載に困っている機能>
|
370
40
|
|
371
|
-
|
41
|
+
①多言語化(とりあえず英語と日本語)
|
372
42
|
|
373
|
-
❎ユーザーの検索機能。 だいたい目測はついた。
|
374
|
-
|
375
|
-
❎記事ごとのコメント機能 カードにつける。
|
376
|
-
|
377
|
-
❎プロフィール画像等の投稿作成
|
378
|
-
|
379
|
-
⑤多言語化(とりあえず英語と日本語)
|
380
|
-
|
381
|
-
|
43
|
+
②デザイニング
|
382
44
|
|
383
45
|
|
384
|
-
|
385
|
-
![全体](5ff4cbe16a89c64dcb1b6b4076e39517.png)
|
386
|
-
|
387
|
-
![コメント](b643dbceff4f341075cf23893b9062f5.png)
|
388
|
-
|
389
|
-
![ポスト](3d0d833e727dad1f1b03c77d22203710.png)
|
390
|
-
|
391
|
-
![ユーザー](5558ba2fcb0814557e162aa8f8dc4cd5.png)
|
392
46
|
|
393
47
|
|
394
48
|
|
75
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -208,9 +208,7 @@
|
|
208
208
|
|
209
209
|
newData.child('uid').val() === auth.uid",
|
210
210
|
|
211
|
-
".validate":"
|
211
|
+
".validate":"newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp'])",
|
212
|
-
|
213
|
-
(newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp','post_image']))",
|
214
212
|
|
215
213
|
|
216
214
|
|
@@ -262,7 +260,7 @@
|
|
262
260
|
|
263
261
|
".write":"auth != null",
|
264
262
|
|
265
|
-
".validate":"
|
263
|
+
".validate":"newData.isNumber()"
|
266
264
|
|
267
265
|
},
|
268
266
|
|
74
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -158,7 +158,7 @@
|
|
158
158
|
|
159
159
|
"starCount":{
|
160
160
|
|
161
|
-
".write":"auth != null
|
161
|
+
".write":"auth != null",
|
162
162
|
|
163
163
|
".validate":"(newData.val() == data.val() + 1 &&
|
164
164
|
|
@@ -198,7 +198,7 @@
|
|
198
198
|
|
199
199
|
".read": true,
|
200
200
|
|
201
|
-
|
201
|
+
".write":"auth != null",
|
202
202
|
|
203
203
|
"$post":{
|
204
204
|
|
@@ -208,9 +208,7 @@
|
|
208
208
|
|
209
209
|
newData.child('uid').val() === auth.uid",
|
210
210
|
|
211
|
-
".validate": "
|
212
|
-
|
213
|
-
|
211
|
+
".validate":"(newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp']))||
|
214
212
|
|
215
213
|
(newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp','post_image']))",
|
216
214
|
|
@@ -220,28 +218,38 @@
|
|
220
218
|
|
221
219
|
"author":{
|
222
220
|
|
221
|
+
".write":"newData.parent().child('uid').val() === auth.uid",
|
222
|
+
|
223
223
|
".validate": "newData.isString() && newData.val().length <= 15",
|
224
224
|
|
225
225
|
},
|
226
226
|
|
227
227
|
"title":{
|
228
228
|
|
229
|
+
".write":"newData.parent().child('uid').val() === auth.uid",
|
230
|
+
|
229
231
|
".validate": "newData.isString() && newData.val().length <= 20",
|
230
232
|
|
231
233
|
},
|
232
234
|
|
233
235
|
"body":{
|
234
236
|
|
237
|
+
".write":"newData.parent().child('uid').val() === auth.uid",
|
238
|
+
|
235
239
|
".validate": "newData.isString() && newData.val().length <= 300",
|
236
240
|
|
237
241
|
},
|
238
242
|
|
239
243
|
"uid":{
|
240
244
|
|
245
|
+
".write":"newData.val() === auth.uid",
|
246
|
+
|
241
247
|
},
|
242
248
|
|
243
249
|
"timestamp":{
|
244
250
|
|
251
|
+
".write":"newData.parent().child('uid').val() === auth.uid",
|
252
|
+
|
245
253
|
},
|
246
254
|
|
247
255
|
"postComment":{
|
@@ -252,9 +260,9 @@
|
|
252
260
|
|
253
261
|
"commentCount":{
|
254
262
|
|
255
|
-
".write":"auth != null
|
263
|
+
".write":"auth != null",
|
256
|
-
|
264
|
+
|
257
|
-
".validate":"(newData.val() == data.val() + 1
|
265
|
+
".validate":"(newData.val() == data.val() + 1) ||(newData.val() == data.val() - 1)"
|
258
266
|
|
259
267
|
},
|
260
268
|
|
@@ -264,7 +272,7 @@
|
|
264
272
|
|
265
273
|
".write":"auth != null &&
|
266
274
|
|
267
|
-
((!data.exists() && newData.exists() &&
|
275
|
+
((!data.exists() && newData.exists() &&
|
268
276
|
|
269
277
|
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() + 1
|
270
278
|
|
@@ -312,6 +320,10 @@
|
|
312
320
|
|
313
321
|
".read": true,
|
314
322
|
|
323
|
+
".write":true,
|
324
|
+
|
325
|
+
|
326
|
+
|
315
327
|
"$comment":{
|
316
328
|
|
317
329
|
".write": "newData.child('uid').val() === auth.uid",
|
73
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,9 +202,17 @@
|
|
202
202
|
|
203
203
|
"$post":{
|
204
204
|
|
205
|
-
".write": "
|
205
|
+
".write": "data.exists() ? (newData.child('uid').val() === auth.uid &&
|
206
|
+
|
206
|
-
|
207
|
+
newData.child('uid').val() === data.child('uid').val()) :
|
208
|
+
|
209
|
+
newData.child('uid').val() === auth.uid",
|
210
|
+
|
211
|
+
".validate": "
|
212
|
+
|
213
|
+
(newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp']))||
|
214
|
+
|
207
|
-
|
215
|
+
(newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp','post_image']))",
|
208
216
|
|
209
217
|
|
210
218
|
|
@@ -246,7 +254,7 @@
|
|
246
254
|
|
247
255
|
".write":"auth != null && newData.isNumber()",
|
248
256
|
|
249
|
-
|
257
|
+
".validate":"(newData.val() == data.val() + 1 )||(newData.val() == data.val() - 1)"
|
250
258
|
|
251
259
|
},
|
252
260
|
|
@@ -256,7 +264,7 @@
|
|
256
264
|
|
257
265
|
".write":"auth != null &&
|
258
266
|
|
259
|
-
(!data.exists() && newData.exists() && newData.child('uid').val() === auth.uid &&
|
267
|
+
((!data.exists() && newData.exists() && newData.child('uid').val() === auth.uid &&
|
260
268
|
|
261
269
|
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() + 1
|
262
270
|
|
@@ -266,7 +274,7 @@
|
|
266
274
|
|
267
275
|
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() - 1
|
268
276
|
|
269
|
-
)",
|
277
|
+
))",
|
270
278
|
|
271
279
|
".validate": "newData.val() == true"
|
272
280
|
|
@@ -306,9 +314,11 @@
|
|
306
314
|
|
307
315
|
"$comment":{
|
308
316
|
|
317
|
+
".write": "newData.child('uid').val() === auth.uid",
|
318
|
+
|
309
319
|
".validate": "newData.hasChildren(['author','body','commentId','uid','profile_image'])",
|
310
320
|
|
311
|
-
|
321
|
+
|
312
322
|
|
313
323
|
}
|
314
324
|
|
72
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -114,7 +114,7 @@
|
|
114
114
|
|
115
115
|
},
|
116
116
|
|
117
|
-
"starred_user":{
|
117
|
+
"starred_users":{
|
118
118
|
|
119
119
|
"$starredUid":{
|
120
120
|
|
@@ -202,11 +202,13 @@
|
|
202
202
|
|
203
203
|
"$post":{
|
204
204
|
|
205
|
-
|
205
|
+
".write": "newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val()",
|
206
|
-
|
206
|
+
|
207
|
-
|
207
|
+
".validate": "newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','timestamp','profile_image'])",
|
208
|
-
|
209
|
-
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
210
212
|
|
211
213
|
"author":{
|
212
214
|
|
@@ -242,7 +244,9 @@
|
|
242
244
|
|
243
245
|
"commentCount":{
|
244
246
|
|
247
|
+
".write":"auth != null && newData.isNumber()",
|
248
|
+
|
245
|
-
|
249
|
+
".validate":"(newData.val() == data.val() + 1 )||(newData.val() == data.val() - 1)"
|
246
250
|
|
247
251
|
},
|
248
252
|
|
@@ -250,7 +254,21 @@
|
|
250
254
|
|
251
255
|
"$commentId":{
|
252
256
|
|
257
|
+
".write":"auth != null &&
|
258
|
+
|
259
|
+
(!data.exists() && newData.exists() && newData.child('uid').val() === auth.uid &&
|
260
|
+
|
261
|
+
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() + 1
|
262
|
+
|
263
|
+
) ||
|
264
|
+
|
265
|
+
(data.exists() && !newData.exists() &&
|
266
|
+
|
267
|
+
newData.parent().parent().child('commentCount').val() == data.parent().parent().child('commentCount').val() - 1
|
268
|
+
|
269
|
+
)",
|
270
|
+
|
253
|
-
|
271
|
+
".validate": "newData.val() == true"
|
254
272
|
|
255
273
|
}
|
256
274
|
|
@@ -288,9 +306,9 @@
|
|
288
306
|
|
289
307
|
"$comment":{
|
290
308
|
|
291
|
-
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
309
|
+
".validate": "newData.hasChildren(['author','body','commentId','uid','profile_image'])",
|
292
|
-
|
310
|
+
|
293
|
-
".write": "
|
311
|
+
".write": "newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val()",
|
294
312
|
|
295
313
|
}
|
296
314
|
|
71
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,38 +58,46 @@
|
|
58
58
|
|
59
59
|
"$uid": {
|
60
60
|
|
61
|
-
".write": "$uid === auth.uid",
|
62
|
-
|
63
|
-
".validate": "
|
61
|
+
".validate": "newData.hasChildren(['explain','profile_image','title','uid','user','userStar'])",
|
64
62
|
|
65
63
|
|
66
64
|
|
67
65
|
"user":{
|
68
66
|
|
67
|
+
".write": "$uid === auth.uid",
|
68
|
+
|
69
69
|
".validate": "newData.isString() && newData.val().length <= 15",
|
70
70
|
|
71
71
|
},
|
72
72
|
|
73
73
|
"uid":{
|
74
74
|
|
75
|
+
".write": "$uid === auth.uid",
|
76
|
+
|
75
77
|
".validate": "newData.isString() && newData.val() == auth.uid",
|
76
78
|
|
77
79
|
},
|
78
80
|
|
79
81
|
"explain":{
|
80
82
|
|
83
|
+
".write": "$uid === auth.uid",
|
84
|
+
|
81
85
|
".validate": "newData.isString() && newData.val().length <= 300",
|
82
86
|
|
83
87
|
},
|
84
88
|
|
85
89
|
"title":{
|
86
90
|
|
91
|
+
".write": "$uid === auth.uid",
|
92
|
+
|
87
93
|
".validate": "newData.isString() && newData.val().length <= 20",
|
88
94
|
|
89
95
|
},
|
90
96
|
|
91
97
|
"profile_image":{
|
92
98
|
|
99
|
+
".write": "$uid === auth.uid",
|
100
|
+
|
93
101
|
".validate": "newData.isString() && newData.val().matches(/^(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*((0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\+&=%\$#_]*)?$/)"
|
94
102
|
|
95
103
|
},
|
@@ -98,6 +106,8 @@
|
|
98
106
|
|
99
107
|
"$postsId":{
|
100
108
|
|
109
|
+
".write": "$uid === auth.uid",
|
110
|
+
|
101
111
|
".validate":"newData.val() === true"
|
102
112
|
|
103
113
|
}
|
@@ -108,172 +118,184 @@
|
|
108
118
|
|
109
119
|
"$starredUid":{
|
110
120
|
|
121
|
+
".write": "$uid === auth.uid",
|
122
|
+
|
111
123
|
".validate":"newData.val() === true",
|
112
124
|
|
113
125
|
},
|
114
126
|
|
115
127
|
},
|
116
128
|
|
117
|
-
"userStar":{
|
129
|
+
"userStar":{
|
118
|
-
|
130
|
+
|
119
|
-
|
131
|
+
".validate":"newData.hasChild('starCount')",
|
132
|
+
|
133
|
+
"stars":{
|
134
|
+
|
135
|
+
"$starUid":{
|
136
|
+
|
137
|
+
".write":"auth.uid == $starUid &&
|
138
|
+
|
139
|
+
(!data.exists() && newData.exists() &&
|
140
|
+
|
141
|
+
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() + 1
|
142
|
+
|
143
|
+
) ||
|
144
|
+
|
145
|
+
(data.exists() && !newData.exists() &&
|
146
|
+
|
147
|
+
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() - 1
|
148
|
+
|
149
|
+
)",
|
150
|
+
|
151
|
+
".validate": "newData.val() == true"
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
},
|
158
|
+
|
159
|
+
"starCount":{
|
160
|
+
|
161
|
+
".write":"auth != null && newData.isNumber()",
|
162
|
+
|
163
|
+
".validate":"(newData.val() == data.val() + 1 &&
|
164
|
+
|
165
|
+
newData.parent().child('stars').child(auth.uid).val() == true &&
|
166
|
+
|
167
|
+
!data.parent().child('stars').child(auth.uid).exists()
|
168
|
+
|
169
|
+
) ||
|
170
|
+
|
171
|
+
(newData.val() == data.val() - 1 &&
|
172
|
+
|
173
|
+
!newData.parent().child('stars').child(auth.uid).exists() &&
|
174
|
+
|
175
|
+
data.parent().child('stars').child(auth.uid).val() == true
|
176
|
+
|
177
|
+
)"
|
178
|
+
|
179
|
+
},
|
180
|
+
|
181
|
+
"$others":{
|
182
|
+
|
183
|
+
".validate":false
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
},
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
"posts":{
|
198
|
+
|
199
|
+
".read": true,
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
"$post":{
|
204
|
+
|
205
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
206
|
+
|
207
|
+
".validate": "data.exists() || newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','profile_image','timestamp'])",
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
"author":{
|
212
|
+
|
213
|
+
".validate": "newData.isString() && newData.val().length <= 15",
|
214
|
+
|
215
|
+
},
|
216
|
+
|
217
|
+
"title":{
|
218
|
+
|
219
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
220
|
+
|
221
|
+
},
|
222
|
+
|
223
|
+
"body":{
|
224
|
+
|
225
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
226
|
+
|
227
|
+
},
|
228
|
+
|
229
|
+
"uid":{
|
230
|
+
|
231
|
+
},
|
232
|
+
|
233
|
+
"timestamp":{
|
234
|
+
|
235
|
+
},
|
236
|
+
|
237
|
+
"postComment":{
|
238
|
+
|
239
|
+
".validate": "newData.hasChild('commentCount')",
|
120
240
|
|
121
241
|
".write":true,
|
122
242
|
|
123
|
-
|
124
|
-
|
125
|
-
"stars":{
|
126
|
-
|
127
|
-
"$starUid":{
|
128
|
-
|
129
|
-
".write": "auth.uid == $starUid",
|
130
|
-
|
131
|
-
".validate": "(!data.exists() && newData.val() == true &&
|
132
|
-
|
133
|
-
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() + 1
|
134
|
-
|
135
|
-
)"
|
136
|
-
|
137
|
-
},
|
138
|
-
|
139
|
-
},
|
140
|
-
|
141
|
-
|
243
|
+
"commentCount":{
|
142
|
-
|
244
|
+
|
143
|
-
|
245
|
+
".validate": "(data.exists()) ? (newData.val() === data.val() + 1):(newData.val() === 0)"
|
144
|
-
|
145
|
-
newData.parent().child('stars').child(auth.uid).val() == true &&
|
146
|
-
|
147
|
-
!data.parent().child('stars').child(auth.uid).exists()
|
148
|
-
|
149
|
-
) ||
|
150
|
-
|
151
|
-
(newData.val() == data.val() - 1 &&
|
152
|
-
|
153
|
-
!newData.parent().child('stars').child(auth.uid).exists() &&
|
154
|
-
|
155
|
-
data.parent().child('stars').child(auth.uid).val() == true
|
156
|
-
|
157
|
-
)",
|
158
|
-
|
159
|
-
".write": "auth != null"
|
160
246
|
|
161
247
|
},
|
162
248
|
|
249
|
+
"comments":{
|
250
|
+
|
251
|
+
"$commentId":{
|
252
|
+
|
253
|
+
".validate": "newData.val() === true"
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
},
|
258
|
+
|
163
|
-
|
259
|
+
"$others": {
|
164
260
|
|
165
261
|
".write": false
|
166
262
|
|
167
|
-
}
|
263
|
+
}
|
168
|
-
|
264
|
+
|
169
|
-
|
265
|
+
},
|
170
|
-
|
171
|
-
|
172
|
-
|
266
|
+
|
173
|
-
|
267
|
+
"postId":{
|
268
|
+
|
174
|
-
|
269
|
+
".write": "$post === newData.val()",
|
270
|
+
|
175
|
-
|
271
|
+
},
|
176
|
-
|
177
|
-
|
178
|
-
|
272
|
+
|
179
|
-
"post
|
273
|
+
"postStar":{
|
274
|
+
|
275
|
+
".write": "newData.val() === data.val() + 1",
|
276
|
+
|
277
|
+
},
|
278
|
+
|
279
|
+
},
|
280
|
+
|
281
|
+
},
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
"comments":{
|
180
286
|
|
181
287
|
".read": true,
|
182
288
|
|
183
|
-
|
184
|
-
|
185
|
-
"$
|
289
|
+
"$comment":{
|
290
|
+
|
186
|
-
|
291
|
+
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
292
|
+
|
187
|
-
|
293
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
188
|
-
|
189
|
-
|
294
|
+
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
"author":{
|
194
|
-
|
195
|
-
".validate": "newData.isString() && newData.val().length <= 15",
|
196
|
-
|
197
|
-
},
|
198
|
-
|
199
|
-
"title":{
|
200
|
-
|
201
|
-
".validate": "newData.isString() && newData.val().length <= 20",
|
202
|
-
|
203
|
-
},
|
204
|
-
|
205
|
-
"body":{
|
206
|
-
|
207
|
-
".validate": "newData.isString() && newData.val().length <= 300",
|
208
|
-
|
209
|
-
},
|
210
|
-
|
211
|
-
"uid":{
|
212
|
-
|
213
|
-
},
|
214
|
-
|
215
|
-
"postComment":{
|
216
|
-
|
217
|
-
".validate": "newData.hasChild('commentCount')",
|
218
|
-
|
219
|
-
".write":true,
|
220
|
-
|
221
|
-
"commentCount":{
|
222
|
-
|
223
|
-
".validate": "(data.exists()) ? (newData.val() === data.val() + 1):(newData.val() === 0)"
|
224
|
-
|
225
|
-
},
|
226
|
-
|
227
|
-
"comments":{
|
228
|
-
|
229
|
-
"$commentId":{
|
230
|
-
|
231
|
-
".validate": "newData.val() === true"
|
232
|
-
|
233
|
-
|
295
|
+
}
|
234
|
-
|
235
|
-
},
|
236
|
-
|
237
|
-
"$others": {
|
238
|
-
|
239
|
-
".write": false
|
240
|
-
|
241
|
-
}
|
242
|
-
|
243
|
-
},
|
244
|
-
|
245
|
-
"postId":{
|
246
|
-
|
247
|
-
".write": "$post === newData.val()",
|
248
|
-
|
249
|
-
},
|
250
|
-
|
251
|
-
"postStar":{
|
252
|
-
|
253
|
-
".write": "newData.val() === data.val() + 1",
|
254
|
-
|
255
|
-
},
|
256
|
-
|
257
|
-
},
|
258
296
|
|
259
297
|
},
|
260
298
|
|
261
|
-
|
262
|
-
|
263
|
-
"comments":{
|
264
|
-
|
265
|
-
".read": true,
|
266
|
-
|
267
|
-
"$comment":{
|
268
|
-
|
269
|
-
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
270
|
-
|
271
|
-
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
},
|
276
|
-
|
277
299
|
|
278
300
|
|
279
301
|
|
70
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
"$uid": {
|
59
|
+
"$uid": {
|
60
60
|
|
61
61
|
".write": "$uid === auth.uid",
|
62
62
|
|
@@ -66,57 +66,49 @@
|
|
66
66
|
|
67
67
|
"user":{
|
68
68
|
|
69
|
-
".write": "$uid === auth.uid",
|
70
|
-
|
71
69
|
".validate": "newData.isString() && newData.val().length <= 15",
|
72
70
|
|
73
71
|
},
|
74
72
|
|
75
73
|
"uid":{
|
76
74
|
|
77
|
-
".write": "$uid == auth.uid",
|
78
|
-
|
79
75
|
".validate": "newData.isString() && newData.val() == auth.uid",
|
80
76
|
|
81
77
|
},
|
82
78
|
|
83
79
|
"explain":{
|
84
80
|
|
85
|
-
".write": "$uid === auth.uid",
|
86
|
-
|
87
81
|
".validate": "newData.isString() && newData.val().length <= 300",
|
88
82
|
|
89
83
|
},
|
90
84
|
|
91
85
|
"title":{
|
92
86
|
|
93
|
-
".write": "$uid === auth.uid",
|
94
|
-
|
95
87
|
".validate": "newData.isString() && newData.val().length <= 20",
|
96
88
|
|
97
89
|
},
|
98
90
|
|
99
91
|
"profile_image":{
|
100
92
|
|
101
|
-
".write": "$uid === auth.uid",
|
102
|
-
|
103
93
|
".validate": "newData.isString() && newData.val().matches(/^(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*((0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\+&=%\$#_]*)?$/)"
|
104
94
|
|
105
95
|
},
|
106
96
|
|
107
97
|
"user_posts":{
|
108
98
|
|
99
|
+
"$postsId":{
|
100
|
+
|
109
|
-
".
|
101
|
+
".validate":"newData.val() === true"
|
102
|
+
|
103
|
+
}
|
110
104
|
|
111
105
|
},
|
112
106
|
|
113
107
|
"starred_user":{
|
114
108
|
|
115
|
-
".write": "$uid === auth.uid",
|
116
|
-
|
117
109
|
"$starredUid":{
|
118
110
|
|
119
|
-
".validate":"
|
111
|
+
".validate":"newData.val() === true",
|
120
112
|
|
121
113
|
},
|
122
114
|
|
@@ -124,25 +116,49 @@
|
|
124
116
|
|
125
117
|
"userStar":{
|
126
118
|
|
127
|
-
".validate":
|
119
|
+
".validate":"newData.hasChild('starCount')",
|
128
120
|
|
129
121
|
".write":true,
|
130
122
|
|
123
|
+
|
124
|
+
|
125
|
+
"stars":{
|
126
|
+
|
127
|
+
"$starUid":{
|
128
|
+
|
129
|
+
".write": "auth.uid == $starUid",
|
130
|
+
|
131
|
+
".validate": "(!data.exists() && newData.val() == true &&
|
132
|
+
|
133
|
+
newData.parent().parent().child('starCount').val() == data.parent().parent().child('starCount').val() + 1
|
134
|
+
|
135
|
+
)"
|
136
|
+
|
137
|
+
},
|
138
|
+
|
139
|
+
},
|
140
|
+
|
131
141
|
"starCount":{
|
132
142
|
|
143
|
+
".validate": "(newData.val() == data.val() + 1 &&
|
144
|
+
|
133
|
-
|
145
|
+
newData.parent().child('stars').child(auth.uid).val() == true &&
|
146
|
+
|
134
|
-
|
147
|
+
!data.parent().child('stars').child(auth.uid).exists()
|
148
|
+
|
149
|
+
) ||
|
150
|
+
|
151
|
+
(newData.val() == data.val() - 1 &&
|
152
|
+
|
153
|
+
!newData.parent().child('stars').child(auth.uid).exists() &&
|
154
|
+
|
155
|
+
data.parent().child('stars').child(auth.uid).val() == true
|
156
|
+
|
157
|
+
)",
|
158
|
+
|
159
|
+
".write": "auth != null"
|
160
|
+
|
135
|
-
|
161
|
+
},
|
136
|
-
|
137
|
-
"stars":{
|
138
|
-
|
139
|
-
"$starUid":{
|
140
|
-
|
141
|
-
".validate": "newData.val() === data.val() ||$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
142
|
-
|
143
|
-
},
|
144
|
-
|
145
|
-
},
|
146
162
|
|
147
163
|
"$others": {
|
148
164
|
|
@@ -170,7 +186,7 @@
|
|
170
186
|
|
171
187
|
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
172
188
|
|
173
|
-
".validate": "data.exists() || newData.hasChildren(['author','body','postComment','postId','postStar','title','uid'])",
|
189
|
+
".validate": "data.exists() || newData.hasChildren(['author','body','postComment','postId','postStar','title','uid','profile_image'])",
|
174
190
|
|
175
191
|
|
176
192
|
|
@@ -194,13 +210,11 @@
|
|
194
210
|
|
195
211
|
"uid":{
|
196
212
|
|
197
|
-
|
198
|
-
|
199
213
|
},
|
200
214
|
|
201
215
|
"postComment":{
|
202
216
|
|
203
|
-
".validate": "
|
217
|
+
".validate": "newData.hasChild('commentCount')",
|
204
218
|
|
205
219
|
".write":true,
|
206
220
|
|
@@ -214,7 +228,7 @@
|
|
214
228
|
|
215
229
|
"$commentId":{
|
216
230
|
|
217
|
-
".validate": "newData.val() ===
|
231
|
+
".validate": "newData.val() === true"
|
218
232
|
|
219
233
|
}
|
220
234
|
|
@@ -260,6 +274,16 @@
|
|
260
274
|
|
261
275
|
},
|
262
276
|
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
"$others": {
|
282
|
+
|
283
|
+
".validate": false
|
284
|
+
|
285
|
+
}
|
286
|
+
|
263
287
|
|
264
288
|
|
265
289
|
|
69
不要な写真削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -306,8 +306,6 @@
|
|
306
306
|
|
307
307
|
![ユーザー](5558ba2fcb0814557e162aa8f8dc4cd5.png)
|
308
308
|
|
309
|
-
![エラー](f166465fc78973ceaa9cd7d8881905b8.png)
|
310
|
-
|
311
309
|
|
312
310
|
|
313
311
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
68
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,12 +126,10 @@
|
|
126
126
|
|
127
127
|
".validate": "data.exists() ? newData.hasChildren(['starCount', 'stars']) : newData.hasChild('starCount')",
|
128
128
|
|
129
|
-
|
129
|
+
".write":true,
|
130
130
|
|
131
131
|
"starCount":{
|
132
132
|
|
133
|
-
".write":true,
|
134
|
-
|
135
133
|
".validate": "data.exists() ? (newData.val() === (data.parent().child('stars').hasChild(auth.uid) ? data.val() - 1 : data.val() + 1)): ($uid === auth.uid && newData.val() === 0)",
|
136
134
|
|
137
135
|
},
|
@@ -140,8 +138,6 @@
|
|
140
138
|
|
141
139
|
"$starUid":{
|
142
140
|
|
143
|
-
".write":true,
|
144
|
-
|
145
141
|
".validate": "newData.val() === data.val() ||$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
146
142
|
|
147
143
|
},
|
@@ -206,12 +202,10 @@
|
|
206
202
|
|
207
203
|
".validate": "data.exists() ? newData.hasChildren(['commentCount', 'comments']) : newData.hasChild('commentCount')",
|
208
204
|
|
209
|
-
|
205
|
+
".write":true,
|
210
206
|
|
211
207
|
"commentCount":{
|
212
208
|
|
213
|
-
".write":true,
|
214
|
-
|
215
209
|
".validate": "(data.exists()) ? (newData.val() === data.val() + 1):(newData.val() === 0)"
|
216
210
|
|
217
211
|
},
|
@@ -220,8 +214,6 @@
|
|
220
214
|
|
221
215
|
"$commentId":{
|
222
216
|
|
223
|
-
".write":true,
|
224
|
-
|
225
217
|
".validate": "newData.val() ===root.child('comments').hasChild('$comment')||(data.exists()?(newData.val() === null) : (newData.val() === true))"
|
226
218
|
|
227
219
|
}
|
@@ -316,8 +308,6 @@
|
|
316
308
|
|
317
309
|
![エラー](f166465fc78973ceaa9cd7d8881905b8.png)
|
318
310
|
|
319
|
-
![シミュレータ](fa58695cc9453d5fc162fb87c275e2df.png)
|
320
|
-
|
321
311
|
|
322
312
|
|
323
313
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
67
ルール更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -124,14 +124,14 @@
|
|
124
124
|
|
125
125
|
"userStar":{
|
126
126
|
|
127
|
-
".write":true,
|
128
|
-
|
129
127
|
".validate": "data.exists() ? newData.hasChildren(['starCount', 'stars']) : newData.hasChild('starCount')",
|
130
128
|
|
131
129
|
|
132
130
|
|
133
131
|
"starCount":{
|
134
132
|
|
133
|
+
".write":true,
|
134
|
+
|
135
135
|
".validate": "data.exists() ? (newData.val() === (data.parent().child('stars').hasChild(auth.uid) ? data.val() - 1 : data.val() + 1)): ($uid === auth.uid && newData.val() === 0)",
|
136
136
|
|
137
137
|
},
|
@@ -140,6 +140,8 @@
|
|
140
140
|
|
141
141
|
"$starUid":{
|
142
142
|
|
143
|
+
".write":true,
|
144
|
+
|
143
145
|
".validate": "newData.val() === data.val() ||$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
144
146
|
|
145
147
|
},
|
@@ -202,14 +204,14 @@
|
|
202
204
|
|
203
205
|
"postComment":{
|
204
206
|
|
205
|
-
".write":true,
|
206
|
-
|
207
207
|
".validate": "data.exists() ? newData.hasChildren(['commentCount', 'comments']) : newData.hasChild('commentCount')",
|
208
208
|
|
209
209
|
|
210
210
|
|
211
211
|
"commentCount":{
|
212
212
|
|
213
|
+
".write":true,
|
214
|
+
|
213
215
|
".validate": "(data.exists()) ? (newData.val() === data.val() + 1):(newData.val() === 0)"
|
214
216
|
|
215
217
|
},
|
@@ -218,7 +220,9 @@
|
|
218
220
|
|
219
221
|
"$commentId":{
|
220
222
|
|
223
|
+
".write":true,
|
224
|
+
|
221
|
-
".validate": "newData.val() ===root.child('comments').
|
225
|
+
".validate": "newData.val() ===root.child('comments').hasChild('$comment')||(data.exists()?(newData.val() === null) : (newData.val() === true))"
|
222
226
|
|
223
227
|
}
|
224
228
|
|
@@ -234,7 +238,7 @@
|
|
234
238
|
|
235
239
|
"postId":{
|
236
240
|
|
237
|
-
".
|
241
|
+
".write": "$post === newData.val()",
|
238
242
|
|
239
243
|
},
|
240
244
|
|
@@ -256,8 +260,6 @@
|
|
256
260
|
|
257
261
|
"$comment":{
|
258
262
|
|
259
|
-
|
260
|
-
|
261
263
|
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
262
264
|
|
263
265
|
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
66
セキュア更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -132,7 +132,7 @@
|
|
132
132
|
|
133
133
|
"starCount":{
|
134
134
|
|
135
|
-
".validate": "data.exists() ? (newData.val() === (data.parent().child('stars').hasChild(auth.uid) ? data.val() - 1 : data.val() + 1)): ($uid === auth.uid && newData.val() === 0)
|
135
|
+
".validate": "data.exists() ? (newData.val() === (data.parent().child('stars').hasChild(auth.uid) ? data.val() - 1 : data.val() + 1)): ($uid === auth.uid && newData.val() === 0)",
|
136
136
|
|
137
137
|
},
|
138
138
|
|
@@ -140,7 +140,7 @@
|
|
140
140
|
|
141
141
|
"$starUid":{
|
142
142
|
|
143
|
-
".validate": "$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
143
|
+
".validate": "newData.val() === data.val() ||$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
144
144
|
|
145
145
|
},
|
146
146
|
|
@@ -202,9 +202,35 @@
|
|
202
202
|
|
203
203
|
"postComment":{
|
204
204
|
|
205
|
-
|
205
|
+
".write":true,
|
206
|
+
|
206
|
-
|
207
|
+
".validate": "data.exists() ? newData.hasChildren(['commentCount', 'comments']) : newData.hasChild('commentCount')",
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
"commentCount":{
|
212
|
+
|
213
|
+
".validate": "(data.exists()) ? (newData.val() === data.val() + 1):(newData.val() === 0)"
|
214
|
+
|
207
|
-
},
|
215
|
+
},
|
216
|
+
|
217
|
+
"comments":{
|
218
|
+
|
219
|
+
"$commentId":{
|
220
|
+
|
221
|
+
".validate": "newData.val() ===root.child('comments').child('$comment').key||(data.exists()?(newData.val() === null) : (newData.val() === true))"
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
},
|
226
|
+
|
227
|
+
"$others": {
|
228
|
+
|
229
|
+
".write": false
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
},
|
208
234
|
|
209
235
|
"postId":{
|
210
236
|
|
65
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,6 +58,8 @@
|
|
58
58
|
|
59
59
|
"$uid": {
|
60
60
|
|
61
|
+
".write": "$uid === auth.uid",
|
62
|
+
|
61
63
|
".validate": "data.exists() || newData.hasChildren(['explain','profile_image','title','uid','user','userStar'])",
|
62
64
|
|
63
65
|
|
@@ -112,11 +114,21 @@
|
|
112
114
|
|
113
115
|
".write": "$uid === auth.uid",
|
114
116
|
|
117
|
+
"$starredUid":{
|
118
|
+
|
119
|
+
".validate":"data.exists() ? (newData.val() === null) : (newData.val() === true)",
|
120
|
+
|
121
|
+
},
|
122
|
+
|
115
123
|
},
|
116
124
|
|
117
125
|
"userStar":{
|
118
126
|
|
127
|
+
".write":true,
|
128
|
+
|
119
|
-
".validate": "newData.hasChildren(['starCount', 'stars'])",
|
129
|
+
".validate": "data.exists() ? newData.hasChildren(['starCount', 'stars']) : newData.hasChild('starCount')",
|
130
|
+
|
131
|
+
|
120
132
|
|
121
133
|
"starCount":{
|
122
134
|
|
64
画像追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -276,6 +276,8 @@
|
|
276
276
|
|
277
277
|
![エラー](f166465fc78973ceaa9cd7d8881905b8.png)
|
278
278
|
|
279
|
+
![シミュレータ](fa58695cc9453d5fc162fb87c275e2df.png)
|
280
|
+
|
279
281
|
|
280
282
|
|
281
283
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
63
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -274,6 +274,8 @@
|
|
274
274
|
|
275
275
|
![ユーザー](5558ba2fcb0814557e162aa8f8dc4cd5.png)
|
276
276
|
|
277
|
+
![エラー](f166465fc78973ceaa9cd7d8881905b8.png)
|
278
|
+
|
277
279
|
|
278
280
|
|
279
281
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
62
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
"uid":{
|
74
74
|
|
75
|
-
".write": "
|
75
|
+
".write": "$uid == auth.uid",
|
76
76
|
|
77
77
|
".validate": "newData.isString() && newData.val() == auth.uid",
|
78
78
|
|
@@ -116,112 +116,118 @@
|
|
116
116
|
|
117
117
|
"userStar":{
|
118
118
|
|
119
|
+
".validate": "newData.hasChildren(['starCount', 'stars'])",
|
120
|
+
|
121
|
+
"starCount":{
|
122
|
+
|
123
|
+
".validate": "data.exists() ? (newData.val() === (data.parent().child('stars').hasChild(auth.uid) ? data.val() - 1 : data.val() + 1)): ($uid === auth.uid && newData.val() === 0) ",
|
124
|
+
|
125
|
+
},
|
126
|
+
|
127
|
+
"stars":{
|
128
|
+
|
129
|
+
"$starUid":{
|
130
|
+
|
131
|
+
".validate": "$starUid === auth.uid && (data.exists() ? (newData.val() === null) : (newData.val() === true))"
|
132
|
+
|
133
|
+
},
|
134
|
+
|
135
|
+
},
|
136
|
+
|
137
|
+
"$others": {
|
138
|
+
|
139
|
+
".write": false
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
"posts":{
|
154
|
+
|
155
|
+
".read": true,
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
"$post":{
|
160
|
+
|
161
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
162
|
+
|
163
|
+
".validate": "data.exists() || newData.hasChildren(['author','body','postComment','postId','postStar','title','uid'])",
|
164
|
+
|
119
165
|
|
120
166
|
|
167
|
+
"author":{
|
168
|
+
|
169
|
+
".validate": "newData.isString() && newData.val().length <= 15",
|
170
|
+
|
171
|
+
},
|
172
|
+
|
173
|
+
"title":{
|
174
|
+
|
175
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
176
|
+
|
177
|
+
},
|
178
|
+
|
179
|
+
"body":{
|
180
|
+
|
181
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
182
|
+
|
183
|
+
},
|
184
|
+
|
185
|
+
"uid":{
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
},
|
190
|
+
|
121
|
-
|
191
|
+
"postComment":{
|
192
|
+
|
193
|
+
|
194
|
+
|
122
|
-
|
195
|
+
},
|
196
|
+
|
197
|
+
"postId":{
|
198
|
+
|
199
|
+
".validate": "$post === newData.val()",
|
200
|
+
|
201
|
+
},
|
202
|
+
|
203
|
+
"postStar":{
|
204
|
+
|
123
|
-
|
205
|
+
".write": "newData.val() === data.val() + 1",
|
124
|
-
|
206
|
+
|
125
|
-
|
207
|
+
},
|
126
|
-
|
127
|
-
|
208
|
+
|
128
|
-
|
129
|
-
"$starUid":{
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
209
|
+
},
|
134
|
-
|
210
|
+
|
135
|
-
|
211
|
+
},
|
136
|
-
|
137
|
-
|
212
|
+
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
213
|
+
|
142
|
-
|
143
|
-
|
214
|
+
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
"
|
215
|
+
"comments":{
|
148
216
|
|
149
217
|
".read": true,
|
150
218
|
|
151
|
-
|
152
|
-
|
153
|
-
"$
|
219
|
+
"$comment":{
|
220
|
+
|
221
|
+
|
222
|
+
|
154
|
-
|
223
|
+
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
224
|
+
|
155
|
-
|
225
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
156
|
-
|
157
|
-
|
226
|
+
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
"author":{
|
162
|
-
|
163
|
-
".validate": "newData.isString() && newData.val().length <= 15",
|
164
|
-
|
165
|
-
|
227
|
+
}
|
166
|
-
|
167
|
-
"title":{
|
168
|
-
|
169
|
-
".validate": "newData.isString() && newData.val().length <= 20",
|
170
|
-
|
171
|
-
},
|
172
|
-
|
173
|
-
"body":{
|
174
|
-
|
175
|
-
".validate": "newData.isString() && newData.val().length <= 300",
|
176
|
-
|
177
|
-
},
|
178
|
-
|
179
|
-
"uid":{
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
},
|
184
|
-
|
185
|
-
"postComment":{
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
},
|
190
|
-
|
191
|
-
"postId":{
|
192
|
-
|
193
|
-
".validate": "$post === newData.val()",
|
194
|
-
|
195
|
-
},
|
196
|
-
|
197
|
-
"postStar":{
|
198
|
-
|
199
|
-
".write": "newData.val() === data.val() + 1",
|
200
|
-
|
201
|
-
},
|
202
|
-
|
203
|
-
},
|
204
228
|
|
205
229
|
},
|
206
230
|
|
207
|
-
|
208
|
-
|
209
|
-
"comments":{
|
210
|
-
|
211
|
-
".read": true,
|
212
|
-
|
213
|
-
"$comment":{
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
218
|
-
|
219
|
-
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
},
|
224
|
-
|
225
231
|
|
226
232
|
|
227
233
|
|
61
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,166 +52,176 @@
|
|
52
52
|
|
53
53
|
"users": {
|
54
54
|
|
55
|
+
".read": true,
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
"$uid": {
|
60
|
+
|
61
|
+
".validate": "data.exists() || newData.hasChildren(['explain','profile_image','title','uid','user','userStar'])",
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
"user":{
|
66
|
+
|
67
|
+
".write": "$uid === auth.uid",
|
68
|
+
|
69
|
+
".validate": "newData.isString() && newData.val().length <= 15",
|
70
|
+
|
71
|
+
},
|
72
|
+
|
73
|
+
"uid":{
|
74
|
+
|
75
|
+
".write": "!data.exists()",
|
76
|
+
|
77
|
+
".validate": "newData.isString() && newData.val() == auth.uid",
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
"explain":{
|
82
|
+
|
83
|
+
".write": "$uid === auth.uid",
|
84
|
+
|
85
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
"title":{
|
90
|
+
|
91
|
+
".write": "$uid === auth.uid",
|
92
|
+
|
93
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
94
|
+
|
95
|
+
},
|
96
|
+
|
97
|
+
"profile_image":{
|
98
|
+
|
99
|
+
".write": "$uid === auth.uid",
|
100
|
+
|
101
|
+
".validate": "newData.isString() && newData.val().matches(/^(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*((0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\+&=%\$#_]*)?$/)"
|
102
|
+
|
103
|
+
},
|
104
|
+
|
105
|
+
"user_posts":{
|
106
|
+
|
107
|
+
".write": "$uid === auth.uid",
|
108
|
+
|
109
|
+
},
|
110
|
+
|
111
|
+
"starred_user":{
|
112
|
+
|
113
|
+
".write": "$uid === auth.uid",
|
114
|
+
|
115
|
+
},
|
116
|
+
|
117
|
+
"userStar":{
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
"starCount":{
|
122
|
+
|
123
|
+
".write": "newData.val() === data.val() + 1",
|
124
|
+
|
125
|
+
},
|
126
|
+
|
127
|
+
"stars":{
|
128
|
+
|
129
|
+
"$starUid":{
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
},
|
134
|
+
|
135
|
+
},
|
136
|
+
|
137
|
+
},
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
"posts":{
|
148
|
+
|
55
149
|
".read": true,
|
56
150
|
|
57
|
-
|
151
|
+
|
58
|
-
|
152
|
+
|
59
|
-
"$
|
153
|
+
"$post":{
|
154
|
+
|
60
|
-
|
155
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
156
|
+
|
157
|
+
".validate": "data.exists() || newData.hasChildren(['author','body','postComment','postId','postStar','title','uid'])",
|
158
|
+
|
159
|
+
|
160
|
+
|
61
|
-
|
161
|
+
"author":{
|
62
|
-
|
63
|
-
".write": "$uid === auth.uid",
|
64
162
|
|
65
163
|
".validate": "newData.isString() && newData.val().length <= 15",
|
66
164
|
|
67
165
|
},
|
68
166
|
|
167
|
+
"title":{
|
168
|
+
|
169
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
170
|
+
|
171
|
+
},
|
172
|
+
|
173
|
+
"body":{
|
174
|
+
|
175
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
176
|
+
|
177
|
+
},
|
178
|
+
|
69
179
|
"uid":{
|
70
180
|
|
71
|
-
|
181
|
+
|
72
|
-
|
73
|
-
|
182
|
+
|
74
|
-
|
75
|
-
},
|
183
|
+
},
|
76
|
-
|
184
|
+
|
77
|
-
"e
|
185
|
+
"postComment":{
|
78
|
-
|
79
|
-
|
186
|
+
|
80
|
-
|
81
|
-
|
187
|
+
|
82
|
-
|
188
|
+
|
83
|
-
},
|
189
|
+
},
|
84
|
-
|
190
|
+
|
85
|
-
"t
|
191
|
+
"postId":{
|
86
|
-
|
192
|
+
|
87
|
-
".
|
193
|
+
".validate": "$post === newData.val()",
|
88
|
-
|
89
|
-
|
194
|
+
|
90
|
-
|
91
|
-
},
|
195
|
+
},
|
92
|
-
|
196
|
+
|
93
|
-
"p
|
197
|
+
"postStar":{
|
94
|
-
|
198
|
+
|
95
|
-
".write": "
|
199
|
+
".write": "newData.val() === data.val() + 1",
|
96
|
-
|
97
|
-
|
200
|
+
|
98
|
-
|
99
|
-
},
|
201
|
+
},
|
100
|
-
|
101
|
-
|
202
|
+
|
102
|
-
|
103
|
-
".write": "$uid === auth.uid",
|
104
|
-
|
105
|
-
|
203
|
+
},
|
106
|
-
|
107
|
-
|
204
|
+
|
108
|
-
|
109
|
-
".write": "$uid === auth.uid",
|
110
|
-
|
111
|
-
|
205
|
+
},
|
112
|
-
|
113
|
-
|
206
|
+
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
207
|
+
|
118
|
-
|
119
|
-
|
208
|
+
|
120
|
-
|
121
|
-
},
|
122
|
-
|
123
|
-
"stars":{
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
},
|
128
|
-
|
129
|
-
},
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
}
|
134
|
-
|
135
|
-
},
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
"
|
209
|
+
"comments":{
|
140
210
|
|
141
211
|
".read": true,
|
142
212
|
|
143
|
-
".validate": "newData.hasChildren(['author','body','postComment','postId','postStar','title','uid'])",
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
"$
|
213
|
+
"$comment":{
|
214
|
+
|
215
|
+
|
216
|
+
|
148
|
-
|
217
|
+
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
218
|
+
|
149
|
-
|
219
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
220
|
+
|
154
|
-
|
155
|
-
".validate": "newData.isString() && newData.val().length <= 15",
|
156
|
-
|
157
|
-
|
221
|
+
}
|
158
|
-
|
159
|
-
"title":{
|
160
|
-
|
161
|
-
".validate": "newData.isString() && newData.val().length <= 20",
|
162
|
-
|
163
|
-
},
|
164
|
-
|
165
|
-
"body":{
|
166
|
-
|
167
|
-
".validate": "newData.isString() && newData.val().length <= 300",
|
168
|
-
|
169
|
-
},
|
170
|
-
|
171
|
-
"uid":{
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
},
|
176
|
-
|
177
|
-
"postComment":{
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
},
|
182
|
-
|
183
|
-
"postId":{
|
184
|
-
|
185
|
-
".validate": "$post === newData.val()",
|
186
|
-
|
187
|
-
},
|
188
|
-
|
189
|
-
"postStar":{
|
190
|
-
|
191
|
-
".write": "newData.val() === data.val() + 1",
|
192
|
-
|
193
|
-
},
|
194
|
-
|
195
|
-
},
|
196
222
|
|
197
223
|
},
|
198
224
|
|
199
|
-
|
200
|
-
|
201
|
-
"comments":{
|
202
|
-
|
203
|
-
".read": true,
|
204
|
-
|
205
|
-
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
206
|
-
|
207
|
-
"$comment":{
|
208
|
-
|
209
|
-
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
},
|
214
|
-
|
215
225
|
|
216
226
|
|
217
227
|
|
60
セキュリティ更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,55 +52,79 @@
|
|
52
52
|
|
53
53
|
"users": {
|
54
54
|
|
55
|
-
".
|
55
|
+
".read": true,
|
56
|
+
|
57
|
+
".validate": "data.exists() || newData.hasChildren(['explain','profile_image','title','uid','user','userStar'])",
|
56
58
|
|
57
59
|
"$uid": {
|
58
60
|
|
59
61
|
"user":{
|
60
62
|
|
61
|
-
".write": "$uid === auth.uid"
|
63
|
+
".write": "$uid === auth.uid",
|
64
|
+
|
65
|
+
".validate": "newData.isString() && newData.val().length <= 15",
|
62
66
|
|
63
67
|
},
|
64
68
|
|
65
69
|
"uid":{
|
66
70
|
|
67
|
-
".write": "
|
71
|
+
".write": "!data.exists()",
|
72
|
+
|
73
|
+
".validate": "newData.isString() && newData.val() == auth.uid",
|
68
74
|
|
69
75
|
},
|
70
76
|
|
71
77
|
"explain":{
|
72
78
|
|
73
|
-
".write": "$uid === auth.uid"
|
79
|
+
".write": "$uid === auth.uid",
|
80
|
+
|
81
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
74
82
|
|
75
83
|
},
|
76
84
|
|
77
85
|
"title":{
|
78
86
|
|
79
|
-
".write": "$uid === auth.uid"
|
87
|
+
".write": "$uid === auth.uid",
|
88
|
+
|
89
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
80
90
|
|
81
91
|
},
|
82
92
|
|
83
93
|
"profile_image":{
|
84
94
|
|
85
|
-
".write": "$uid === auth.uid"
|
95
|
+
".write": "$uid === auth.uid",
|
96
|
+
|
97
|
+
".validate": "newData.isString() && newData.val().matches(/^(ht|f)tp(s?):\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*((0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\+&=%\$#_]*)?$/)"
|
86
98
|
|
87
99
|
},
|
88
100
|
|
89
101
|
"user_posts":{
|
90
102
|
|
91
|
-
".write": "$uid === auth.uid"
|
103
|
+
".write": "$uid === auth.uid",
|
92
104
|
|
93
105
|
},
|
94
106
|
|
95
107
|
"starred_user":{
|
96
108
|
|
97
|
-
".write": "$uid === auth.uid"
|
109
|
+
".write": "$uid === auth.uid",
|
98
110
|
|
99
111
|
},
|
100
112
|
|
101
113
|
"userStar":{
|
102
114
|
|
115
|
+
|
116
|
+
|
117
|
+
"starCount":{
|
118
|
+
|
119
|
+
".write": "newData.val() === data.val() + 1",
|
120
|
+
|
121
|
+
},
|
122
|
+
|
103
|
-
"
|
123
|
+
"stars":{
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
},
|
104
128
|
|
105
129
|
},
|
106
130
|
|
@@ -114,51 +138,59 @@
|
|
114
138
|
|
115
139
|
"posts":{
|
116
140
|
|
117
|
-
".
|
141
|
+
".read": true,
|
142
|
+
|
143
|
+
".validate": "newData.hasChildren(['author','body','postComment','postId','postStar','title','uid'])",
|
144
|
+
|
145
|
+
|
118
146
|
|
119
147
|
"$post":{
|
120
148
|
|
149
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
150
|
+
|
151
|
+
|
152
|
+
|
121
|
-
|
153
|
+
"author":{
|
122
|
-
|
154
|
+
|
123
|
-
".
|
155
|
+
".validate": "newData.isString() && newData.val().length <= 15",
|
156
|
+
|
157
|
+
},
|
158
|
+
|
159
|
+
"title":{
|
160
|
+
|
161
|
+
".validate": "newData.isString() && newData.val().length <= 20",
|
124
162
|
|
125
163
|
},
|
126
164
|
|
127
165
|
"body":{
|
128
166
|
|
129
|
-
".
|
167
|
+
".validate": "newData.isString() && newData.val().length <= 300",
|
130
|
-
|
168
|
+
|
131
|
-
},
|
169
|
+
},
|
132
|
-
|
170
|
+
|
133
|
-
"
|
171
|
+
"uid":{
|
172
|
+
|
173
|
+
|
174
|
+
|
134
|
-
|
175
|
+
},
|
176
|
+
|
135
|
-
|
177
|
+
"postComment":{
|
178
|
+
|
179
|
+
|
136
180
|
|
137
181
|
},
|
138
182
|
|
139
183
|
"postId":{
|
140
184
|
|
141
|
-
".
|
185
|
+
".validate": "$post === newData.val()",
|
142
|
-
|
143
|
-
},
|
144
|
-
|
145
|
-
"uid":{
|
146
|
-
|
147
|
-
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
148
|
-
|
149
|
-
},
|
150
|
-
|
151
|
-
"postComment":{
|
152
|
-
|
153
|
-
".write":true,
|
154
186
|
|
155
187
|
},
|
156
188
|
|
157
189
|
"postStar":{
|
158
190
|
|
159
|
-
".write":t
|
191
|
+
".write": "newData.val() === data.val() + 1",
|
160
|
-
|
192
|
+
|
161
|
-
},
|
193
|
+
},
|
162
194
|
|
163
195
|
},
|
164
196
|
|
@@ -168,11 +200,13 @@
|
|
168
200
|
|
169
201
|
"comments":{
|
170
202
|
|
203
|
+
".read": true,
|
204
|
+
|
171
|
-
".validate": "newData.hasChildren()",
|
205
|
+
".validate": "newData.hasChildren(['author','body','commentId','uid'])",
|
172
206
|
|
173
207
|
"$comment":{
|
174
208
|
|
175
|
-
".write": "!data.exists()
|
209
|
+
".write": "!data.exists() || (newData.child('uid').val() === auth.uid && newData.child('uid').val() === data.child('uid').val())",
|
176
210
|
|
177
211
|
}
|
178
212
|
|
59
写真追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -216,11 +216,13 @@
|
|
216
216
|
|
217
217
|
|
218
218
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
![
|
219
|
+
![全体](5ff4cbe16a89c64dcb1b6b4076e39517.png)
|
220
|
+
|
221
|
+
![コメント](b643dbceff4f341075cf23893b9062f5.png)
|
222
|
+
|
223
|
+
![ポスト](3d0d833e727dad1f1b03c77d22203710.png)
|
224
|
+
|
225
|
+
![ユーザー](5558ba2fcb0814557e162aa8f8dc4cd5.png)
|
224
226
|
|
225
227
|
|
226
228
|
|
58
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,15 +26,169 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
不明点(
|
29
|
+
不明点(セキュリティルール)
|
30
30
|
|
31
31
|
---
|
32
32
|
|
33
|
-
|
33
|
+
ルール設定に四苦八苦しています。
|
34
|
+
|
35
|
+
|
36
|
+
|
34
|
-
|
37
|
+
ルール
|
38
|
+
|
35
|
-
```
|
39
|
+
```JSON
|
40
|
+
|
36
|
-
|
41
|
+
{
|
42
|
+
|
43
|
+
|
44
|
+
|
37
|
-
|
45
|
+
"rules": {
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
".read": true,
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
"users": {
|
54
|
+
|
55
|
+
".validate": "newData.hasChildren()",
|
56
|
+
|
57
|
+
"$uid": {
|
58
|
+
|
59
|
+
"user":{
|
60
|
+
|
61
|
+
".write": "$uid === auth.uid"
|
62
|
+
|
63
|
+
},
|
64
|
+
|
65
|
+
"uid":{
|
66
|
+
|
67
|
+
".write": "$uid === auth.uid"
|
68
|
+
|
69
|
+
},
|
70
|
+
|
71
|
+
"explain":{
|
72
|
+
|
73
|
+
".write": "$uid === auth.uid"
|
74
|
+
|
75
|
+
},
|
76
|
+
|
77
|
+
"title":{
|
78
|
+
|
79
|
+
".write": "$uid === auth.uid"
|
80
|
+
|
81
|
+
},
|
82
|
+
|
83
|
+
"profile_image":{
|
84
|
+
|
85
|
+
".write": "$uid === auth.uid"
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
"user_posts":{
|
90
|
+
|
91
|
+
".write": "$uid === auth.uid"
|
92
|
+
|
93
|
+
},
|
94
|
+
|
95
|
+
"starred_user":{
|
96
|
+
|
97
|
+
".write": "$uid === auth.uid"
|
98
|
+
|
99
|
+
},
|
100
|
+
|
101
|
+
"userStar":{
|
102
|
+
|
103
|
+
".write":true,
|
104
|
+
|
105
|
+
},
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
},
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
"posts":{
|
116
|
+
|
117
|
+
".validate": "newData.hasChildren()",
|
118
|
+
|
119
|
+
"$post":{
|
120
|
+
|
121
|
+
"author":{
|
122
|
+
|
123
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
124
|
+
|
125
|
+
},
|
126
|
+
|
127
|
+
"body":{
|
128
|
+
|
129
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
130
|
+
|
131
|
+
},
|
132
|
+
|
133
|
+
"title":{
|
134
|
+
|
135
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
136
|
+
|
137
|
+
},
|
138
|
+
|
139
|
+
"postId":{
|
140
|
+
|
141
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
142
|
+
|
143
|
+
},
|
144
|
+
|
145
|
+
"uid":{
|
146
|
+
|
147
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
148
|
+
|
149
|
+
},
|
150
|
+
|
151
|
+
"postComment":{
|
152
|
+
|
153
|
+
".write":true,
|
154
|
+
|
155
|
+
},
|
156
|
+
|
157
|
+
"postStar":{
|
158
|
+
|
159
|
+
".write":true,
|
160
|
+
|
161
|
+
},
|
162
|
+
|
163
|
+
},
|
164
|
+
|
165
|
+
},
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
"comments":{
|
170
|
+
|
171
|
+
".validate": "newData.hasChildren()",
|
172
|
+
|
173
|
+
"$comment":{
|
174
|
+
|
175
|
+
".write": "!data.exists() && newData.child('uid').val() == auth.uid"
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
},
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
}
|
38
192
|
|
39
193
|
```
|
40
194
|
|
57
改変
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
ーー(ページごとにユーザーのみ、ゲストのみと分けたい。)
|
10
10
|
|
11
|
-
進行中→●ゲスト、ユーザーが見れるプラットホーム。
|
11
|
+
進行中→●ゲスト、ユーザーが見れるプラットホーム。(ほぼ完成。これから投稿の時間等も管理したいと思います。)
|
12
12
|
|
13
13
|
ーー(ユーザーが投稿した内容が時系列で表示)
|
14
14
|
|
@@ -16,357 +16,31 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
|
19
|
+
現在のプロジェクトは[こちら。](http://plzdonation-56b64.firebaseapp.com)
|
20
20
|
|
21
21
|
|
22
22
|
|
23
23
|
テストサーバーはreact-scripts startにて。
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
ホスティングサーバーはfirebaseにて。
|
28
|
-
|
29
|
-
reduxは使いたくない!再三のバグ襲来に疲れました。
|
30
26
|
|
31
27
|
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
不明点(
|
29
|
+
不明点(firebase realtime Databaseに投稿時間を送る。)
|
36
30
|
|
37
31
|
---
|
38
32
|
|
39
|
-
|
33
|
+
投稿時間を取得し、データーベースに送りたいです。
|
40
34
|
|
41
35
|
```js
|
42
36
|
|
43
|
-
onChange = (pictures) => this.setState({pictures})
|
44
37
|
|
45
|
-
|
46
|
-
|
47
|
-
componentDidMount(){
|
48
|
-
|
49
|
-
const self=this
|
50
|
-
|
51
|
-
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
52
|
-
|
53
|
-
if(user){
|
54
|
-
|
55
|
-
self.setState({
|
56
|
-
|
57
|
-
userId : firebase.auth().currentUser.uid
|
58
|
-
|
59
|
-
})
|
60
|
-
|
61
|
-
}else {
|
62
|
-
|
63
|
-
self.props.history.push('/login')
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
})
|
68
|
-
|
69
|
-
this.setState({unsub});
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
handleChange_username = (event) => {
|
78
|
-
|
79
|
-
this.setState({
|
80
|
-
|
81
|
-
username: event.target.value
|
82
|
-
|
83
|
-
})
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
handleChange_title = (event) => {
|
90
|
-
|
91
|
-
this.setState({
|
92
|
-
|
93
|
-
title: event.target.value
|
94
|
-
|
95
|
-
})
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
handleChange_explain = (event) => {
|
102
|
-
|
103
|
-
this.setState({
|
104
|
-
|
105
|
-
explain: event.target.value
|
106
|
-
|
107
|
-
})
|
108
|
-
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
upLoadFile(){
|
114
|
-
|
115
|
-
const self = this
|
116
|
-
|
117
|
-
var file = this.state.pictures
|
118
|
-
|
119
|
-
var metadata = {
|
120
|
-
|
121
|
-
contentType: 'image/jpeg'
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
var uploadTask = firebase.storage().ref().child('profile_images/' + self.state.userId).put(file, metadata);
|
126
|
-
|
127
|
-
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
|
128
|
-
|
129
|
-
function(snapshot) {
|
130
|
-
|
131
|
-
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
|
132
|
-
|
133
|
-
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
console.log('Upload is ' + progress + '% done')
|
138
|
-
|
139
|
-
switch (snapshot.state) {
|
140
|
-
|
141
|
-
case firebase.storage.TaskState.PAUSED:
|
142
|
-
|
143
|
-
console.log('Upload is paused');
|
144
|
-
|
145
|
-
break;
|
146
|
-
|
147
|
-
case firebase.storage.TaskState.RUNNING:
|
148
|
-
|
149
|
-
console.log('Upload is running');
|
150
|
-
|
151
|
-
break;
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
}, function(error) {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
// A full list of error codes is available at
|
160
|
-
|
161
|
-
// https://firebase.google.com/docs/storage/web/handle-errors
|
162
|
-
|
163
|
-
switch (error.code) {
|
164
|
-
|
165
|
-
case 'storage/unauthorized':
|
166
|
-
|
167
|
-
// User doesn't have permission to access the object
|
168
|
-
|
169
|
-
break;
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
case 'storage/canceled':
|
174
|
-
|
175
|
-
// User canceled the upload
|
176
|
-
|
177
|
-
break;
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
case 'storage/unknown':
|
184
|
-
|
185
|
-
// Unknown error occurred, inspect error.serverResponse
|
186
|
-
|
187
|
-
break;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
}, function() {
|
192
|
-
|
193
|
-
var downloadURL = uploadTask.snapshot.downloadURL;
|
194
|
-
|
195
|
-
firebase.database().ref('users/' + this.state.userId).set({
|
196
|
-
|
197
|
-
title: this.state.title,
|
198
|
-
|
199
|
-
user: this.state.username,
|
200
|
-
|
201
|
-
explain: this.state.explain,
|
202
|
-
|
203
|
-
uid:this.state.userId,
|
204
|
-
|
205
|
-
profile_image:downloadURL,
|
206
|
-
|
207
|
-
userStar:{
|
208
|
-
|
209
|
-
starCount:0,
|
210
|
-
|
211
|
-
stars:{}
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
})
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
this.props.history.push('/')
|
220
|
-
|
221
|
-
window.alert("you can successfully make your page!")
|
222
|
-
|
223
|
-
})
|
224
|
-
|
225
|
-
}
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
handleSubmit = () =>{
|
230
|
-
|
231
|
-
this.upLoadFile()
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
componentWillUnmount() {
|
238
|
-
|
239
|
-
this.state.unsub();
|
240
|
-
|
241
|
-
};
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
render() {
|
248
|
-
|
249
|
-
return (
|
250
|
-
|
251
|
-
<div>
|
252
|
-
|
253
|
-
<div className='col s12 m4'>
|
254
|
-
|
255
|
-
<br />
|
256
|
-
|
257
|
-
<br />
|
258
|
-
|
259
|
-
<br />
|
260
|
-
|
261
|
-
<Card>
|
262
|
-
|
263
|
-
<CardTitle title='Make my page' subtitle='make your top page and explanation'/>
|
264
|
-
|
265
|
-
<CardText
|
266
|
-
|
267
|
-
style={{
|
268
|
-
|
269
|
-
width: '35%',
|
270
|
-
|
271
|
-
margin: 'auto',
|
272
|
-
|
273
|
-
}}
|
274
|
-
|
275
|
-
>
|
276
|
-
|
277
|
-
<TextField
|
278
|
-
|
279
|
-
id="username"
|
280
|
-
|
281
|
-
floatingLabelText="type the shown username"
|
282
|
-
|
283
|
-
value={this.state.username}
|
284
|
-
|
285
|
-
onChange={this.handleChange_username}
|
286
|
-
|
287
|
-
/>
|
288
|
-
|
289
|
-
<br />
|
290
|
-
|
291
|
-
<TextField
|
292
|
-
|
293
|
-
id="title"
|
294
|
-
|
295
|
-
floatingLabelText="type the title"
|
296
|
-
|
297
|
-
value={this.state.currentItem}
|
298
|
-
|
299
|
-
onChange={this.handleChange_title}
|
300
|
-
|
301
|
-
/>
|
302
|
-
|
303
|
-
<br />
|
304
|
-
|
305
|
-
<TextField
|
306
|
-
|
307
|
-
floatingLabelText="explaination"
|
308
|
-
|
309
|
-
multiLine={true}
|
310
|
-
|
311
|
-
value={this.state.explain}
|
312
|
-
|
313
|
-
onChange={this.handleChange_explain}
|
314
|
-
|
315
|
-
rows={5}
|
316
|
-
|
317
|
-
style={{
|
318
|
-
|
319
|
-
border: '1px solid #EEEEEE',
|
320
|
-
|
321
|
-
}}
|
322
|
-
|
323
|
-
/>
|
324
|
-
|
325
|
-
<UploadPreview
|
326
|
-
|
327
|
-
title="profile image"
|
328
|
-
|
329
|
-
label="Add"
|
330
|
-
|
331
|
-
initialItems={this.state.pictures}
|
332
|
-
|
333
|
-
onChange={this.onChange}
|
334
|
-
|
335
|
-
/>
|
336
|
-
|
337
|
-
<br />
|
338
|
-
|
339
|
-
<RaisedButton
|
340
|
-
|
341
|
-
label="make Your page"
|
342
|
-
|
343
|
-
secondary={true}
|
344
|
-
|
345
|
-
onClick={this.handleSubmit}
|
346
|
-
|
347
|
-
/>
|
348
|
-
|
349
|
-
<br />
|
350
|
-
|
351
|
-
</CardText>
|
352
|
-
|
353
|
-
</Card>
|
354
|
-
|
355
|
-
</div>
|
356
|
-
|
357
|
-
</div>
|
358
|
-
|
359
|
-
)}
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
export default makeMyPage
|
364
38
|
|
365
39
|
```
|
366
40
|
|
367
41
|
|
368
42
|
|
369
|
-
|
43
|
+
|
370
44
|
|
371
45
|
|
372
46
|
|
@@ -380,13 +54,15 @@
|
|
380
54
|
|
381
55
|
❎記事ごとのコメント機能 カードにつける。
|
382
56
|
|
383
|
-
|
57
|
+
❎プロフィール画像等の投稿作成
|
58
|
+
|
59
|
+
⑤多言語化(とりあえず英語と日本語)
|
384
60
|
|
385
61
|
などがあります。
|
386
62
|
|
387
63
|
|
388
64
|
|
389
|
-
|
65
|
+
|
390
66
|
|
391
67
|
|
392
68
|
|
56
不明点更新。
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,11 +40,335 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
|
43
|
+
onChange = (pictures) => this.setState({pictures})
|
44
|
+
|
45
|
+
|
46
|
+
|
44
|
-
|
47
|
+
componentDidMount(){
|
48
|
+
|
49
|
+
const self=this
|
50
|
+
|
51
|
+
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
52
|
+
|
53
|
+
if(user){
|
54
|
+
|
55
|
+
self.setState({
|
56
|
+
|
57
|
+
userId : firebase.auth().currentUser.uid
|
58
|
+
|
59
|
+
})
|
60
|
+
|
61
|
+
}else {
|
62
|
+
|
63
|
+
self.props.history.push('/login')
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
})
|
68
|
+
|
69
|
+
this.setState({unsub});
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
handleChange_username = (event) => {
|
78
|
+
|
79
|
+
this.setState({
|
80
|
+
|
81
|
+
username: event.target.value
|
82
|
+
|
83
|
+
})
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
handleChange_title = (event) => {
|
90
|
+
|
91
|
+
this.setState({
|
92
|
+
|
93
|
+
title: event.target.value
|
94
|
+
|
95
|
+
})
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
handleChange_explain = (event) => {
|
102
|
+
|
103
|
+
this.setState({
|
104
|
+
|
105
|
+
explain: event.target.value
|
106
|
+
|
107
|
+
})
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
upLoadFile(){
|
114
|
+
|
115
|
+
const self = this
|
116
|
+
|
117
|
+
var file = this.state.pictures
|
118
|
+
|
119
|
+
var metadata = {
|
120
|
+
|
121
|
+
contentType: 'image/jpeg'
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
var uploadTask = firebase.storage().ref().child('profile_images/' + self.state.userId).put(file, metadata);
|
126
|
+
|
127
|
+
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
|
128
|
+
|
129
|
+
function(snapshot) {
|
130
|
+
|
131
|
+
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
|
132
|
+
|
133
|
+
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
console.log('Upload is ' + progress + '% done')
|
138
|
+
|
139
|
+
switch (snapshot.state) {
|
140
|
+
|
141
|
+
case firebase.storage.TaskState.PAUSED:
|
142
|
+
|
143
|
+
console.log('Upload is paused');
|
144
|
+
|
145
|
+
break;
|
146
|
+
|
147
|
+
case firebase.storage.TaskState.RUNNING:
|
148
|
+
|
149
|
+
console.log('Upload is running');
|
150
|
+
|
151
|
+
break;
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
}, function(error) {
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
// A full list of error codes is available at
|
160
|
+
|
161
|
+
// https://firebase.google.com/docs/storage/web/handle-errors
|
162
|
+
|
163
|
+
switch (error.code) {
|
164
|
+
|
165
|
+
case 'storage/unauthorized':
|
166
|
+
|
167
|
+
// User doesn't have permission to access the object
|
168
|
+
|
169
|
+
break;
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
case 'storage/canceled':
|
174
|
+
|
175
|
+
// User canceled the upload
|
176
|
+
|
177
|
+
break;
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
case 'storage/unknown':
|
184
|
+
|
185
|
+
// Unknown error occurred, inspect error.serverResponse
|
186
|
+
|
187
|
+
break;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
}, function() {
|
192
|
+
|
193
|
+
var downloadURL = uploadTask.snapshot.downloadURL;
|
194
|
+
|
195
|
+
firebase.database().ref('users/' + this.state.userId).set({
|
196
|
+
|
197
|
+
title: this.state.title,
|
198
|
+
|
199
|
+
user: this.state.username,
|
200
|
+
|
201
|
+
explain: this.state.explain,
|
202
|
+
|
203
|
+
uid:this.state.userId,
|
204
|
+
|
205
|
+
profile_image:downloadURL,
|
206
|
+
|
207
|
+
userStar:{
|
208
|
+
|
209
|
+
starCount:0,
|
210
|
+
|
211
|
+
stars:{}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
})
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
this.props.history.push('/')
|
220
|
+
|
221
|
+
window.alert("you can successfully make your page!")
|
222
|
+
|
223
|
+
})
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
handleSubmit = () =>{
|
230
|
+
|
231
|
+
this.upLoadFile()
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
componentWillUnmount() {
|
238
|
+
|
239
|
+
this.state.unsub();
|
240
|
+
|
241
|
+
};
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
render() {
|
248
|
+
|
249
|
+
return (
|
250
|
+
|
251
|
+
<div>
|
252
|
+
|
253
|
+
<div className='col s12 m4'>
|
254
|
+
|
255
|
+
<br />
|
256
|
+
|
257
|
+
<br />
|
258
|
+
|
259
|
+
<br />
|
260
|
+
|
261
|
+
<Card>
|
262
|
+
|
263
|
+
<CardTitle title='Make my page' subtitle='make your top page and explanation'/>
|
264
|
+
|
265
|
+
<CardText
|
266
|
+
|
267
|
+
style={{
|
268
|
+
|
269
|
+
width: '35%',
|
270
|
+
|
271
|
+
margin: 'auto',
|
272
|
+
|
273
|
+
}}
|
274
|
+
|
275
|
+
>
|
276
|
+
|
277
|
+
<TextField
|
278
|
+
|
279
|
+
id="username"
|
280
|
+
|
281
|
+
floatingLabelText="type the shown username"
|
282
|
+
|
283
|
+
value={this.state.username}
|
284
|
+
|
285
|
+
onChange={this.handleChange_username}
|
286
|
+
|
287
|
+
/>
|
288
|
+
|
289
|
+
<br />
|
290
|
+
|
291
|
+
<TextField
|
292
|
+
|
293
|
+
id="title"
|
294
|
+
|
295
|
+
floatingLabelText="type the title"
|
296
|
+
|
297
|
+
value={this.state.currentItem}
|
298
|
+
|
299
|
+
onChange={this.handleChange_title}
|
300
|
+
|
301
|
+
/>
|
302
|
+
|
303
|
+
<br />
|
304
|
+
|
305
|
+
<TextField
|
306
|
+
|
307
|
+
floatingLabelText="explaination"
|
308
|
+
|
309
|
+
multiLine={true}
|
310
|
+
|
311
|
+
value={this.state.explain}
|
312
|
+
|
313
|
+
onChange={this.handleChange_explain}
|
314
|
+
|
315
|
+
rows={5}
|
316
|
+
|
317
|
+
style={{
|
318
|
+
|
319
|
+
border: '1px solid #EEEEEE',
|
320
|
+
|
321
|
+
}}
|
322
|
+
|
323
|
+
/>
|
324
|
+
|
325
|
+
<UploadPreview
|
326
|
+
|
327
|
+
title="profile image"
|
328
|
+
|
329
|
+
label="Add"
|
330
|
+
|
331
|
+
initialItems={this.state.pictures}
|
332
|
+
|
333
|
+
onChange={this.onChange}
|
334
|
+
|
335
|
+
/>
|
336
|
+
|
337
|
+
<br />
|
338
|
+
|
339
|
+
<RaisedButton
|
340
|
+
|
341
|
+
label="make Your page"
|
342
|
+
|
343
|
+
secondary={true}
|
344
|
+
|
345
|
+
onClick={this.handleSubmit}
|
346
|
+
|
347
|
+
/>
|
348
|
+
|
349
|
+
<br />
|
350
|
+
|
351
|
+
</CardText>
|
352
|
+
|
353
|
+
</Card>
|
354
|
+
|
355
|
+
</div>
|
356
|
+
|
357
|
+
</div>
|
358
|
+
|
359
|
+
)}
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
export default makeMyPage
|
364
|
+
|
45
|
-
```
|
365
|
+
```
|
46
|
-
|
366
|
+
|
367
|
+
|
368
|
+
|
47
|
-
|
369
|
+
makeMyPageのstate以下のコードです。
|
370
|
+
|
371
|
+
|
48
372
|
|
49
373
|
|
50
374
|
|
@@ -54,23 +378,19 @@
|
|
54
378
|
|
55
379
|
❎ユーザーの検索機能。 だいたい目測はついた。
|
56
380
|
|
57
|
-
|
381
|
+
❎記事ごとのコメント機能 カードにつける。
|
382
|
+
|
58
|
-
|
383
|
+
④プロフィール画像等の投稿作成
|
59
|
-
|
60
384
|
|
61
385
|
などがあります。
|
62
386
|
|
63
387
|
|
64
388
|
|
65
|
-
|
66
|
-
|
67
|
-
現在
|
389
|
+
現在画像の扱いを調整中。
|
68
|
-
|
69
|
-
|
70
|
-
|
390
|
+
|
391
|
+
|
392
|
+
|
71
|
-
![
|
393
|
+
![現在のプロジェクトの見た目](961c7316f1ec0b9731fe8ab2c5a9d483.png)
|
72
|
-
|
73
|
-
![コメント開いた状態](dd10a29835891dc9da4f86443c12defd.png)
|
74
394
|
|
75
395
|
|
76
396
|
|
55
表示の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,629 +40,9 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
/*------------refer starred user-------------------------------------------------------------------*/
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
fetchStarredUser(onchange) {
|
48
|
-
|
49
|
-
const self1 = this
|
50
|
-
|
51
|
-
const myUserId = self1.state.userId
|
52
|
-
|
53
|
-
var onValueChange1 = firebase.database().ref('/users/' + myUserId + '/starred_users').on('value', function(snapshot) {
|
54
|
-
|
55
|
-
const starred_users = [];
|
56
|
-
|
57
|
-
snapshot.forEach(function(childSnapshot) {
|
58
|
-
|
59
|
-
starred_users.push(childSnapshot.val().starUserData)
|
60
|
-
|
61
|
-
})
|
62
|
-
|
63
|
-
self1.setState({
|
64
|
-
|
65
|
-
starred_users: starred_users
|
66
|
-
|
67
|
-
}, function() {
|
68
|
-
|
69
|
-
if (onchange) onchange();
|
70
|
-
|
71
|
-
});
|
72
|
-
|
73
|
-
});
|
74
|
-
|
75
|
-
this.setState({
|
76
|
-
|
77
|
-
off_starred_user: onValueChange1
|
78
|
-
|
79
|
-
})
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
fetchStarredUserPosts() {
|
86
|
-
|
87
|
-
const self2 = this
|
88
|
-
|
89
|
-
const posts = [];
|
90
|
-
|
91
|
-
const stateStarredUsers = this.state.starred_users
|
92
|
-
|
93
|
-
for (var i = 0; i < stateStarredUsers.length; i++) {
|
94
|
-
|
95
|
-
const starredUser = stateStarredUsers[i]
|
96
|
-
|
97
|
-
firebase.database().ref('/users/' + starredUser + '/user_posts/').limitToFirst(1).once('value', function(snapshot) {
|
98
|
-
|
99
|
-
snapshot.forEach(function(childSnapshot) {
|
100
|
-
|
101
|
-
posts.push(childSnapshot.val())
|
102
|
-
|
103
|
-
self2.setState({
|
104
|
-
|
105
|
-
starred_posts: posts
|
106
|
-
|
107
|
-
});
|
108
|
-
|
109
|
-
})
|
110
|
-
|
111
|
-
});
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
fetchAllStarUser() {
|
120
|
-
|
121
|
-
const self = this
|
122
|
-
|
123
|
-
this.fetchStarredUser(function() {
|
124
|
-
|
125
|
-
self.fetchStarredUserPosts()
|
126
|
-
|
127
|
-
})
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
/*------------comment function open------------------------------------------------------------------------*/
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
commentFncOpen(uid,postId){
|
142
|
-
|
143
|
-
this.setState({
|
144
|
-
|
145
|
-
commentForm:true,
|
146
|
-
|
147
|
-
comment_uid:uid,
|
148
|
-
|
149
|
-
commentPostId:postId
|
150
|
-
|
151
|
-
})
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
/*------------life cicle method--------------------------------------------------------------------*/
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
componentWillMount(){
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
componentDidMount(){
|
172
|
-
|
173
|
-
const self=this
|
174
|
-
|
175
|
-
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
176
|
-
|
177
|
-
if(user){
|
178
|
-
|
179
|
-
self.setState({
|
180
|
-
|
181
|
-
userId : firebase.auth().currentUser.uid
|
182
|
-
|
183
|
-
},self.fetchAllStarUser);
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
else {
|
188
|
-
|
189
|
-
self.props.history.push('/login')
|
190
|
-
|
191
|
-
}
|
192
|
-
|
193
|
-
})
|
194
|
-
|
195
|
-
this.setState({unsub});
|
196
|
-
|
197
|
-
}
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
componentWillUnmount() {
|
202
|
-
|
203
|
-
const self = this
|
204
|
-
|
205
|
-
this.state.unsub();
|
206
|
-
|
207
|
-
firebase.database().ref('/users/'+this.state.userId+'/starred_users/').off('value', self.state.off)
|
208
|
-
|
209
|
-
};
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
/*------------search reference method--------------------------------------------------------------*/
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
handleChange_search = (event) => {
|
218
|
-
|
219
|
-
this.setState({
|
220
|
-
|
221
|
-
search: event.target.value,
|
222
|
-
|
223
|
-
});
|
224
|
-
|
225
|
-
};
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
handleSearch = (event) =>{
|
230
|
-
|
231
|
-
const self = this
|
232
|
-
|
233
|
-
firebase.database().ref('/users/').orderByChild('user').startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value").then(function(snapshot) {
|
234
|
-
|
235
|
-
const search_users =[]
|
236
|
-
|
237
|
-
snapshot.forEach(function(childSnapshot) {
|
238
|
-
|
239
|
-
search_users.push(childSnapshot.val())
|
240
|
-
|
241
|
-
})
|
242
|
-
|
243
|
-
self.setState({
|
244
|
-
|
245
|
-
search_users:search_users,
|
246
|
-
|
247
|
-
});
|
248
|
-
|
249
|
-
})
|
250
|
-
|
251
|
-
this.setState({searchReference:'1'});
|
252
|
-
|
253
|
-
}
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
/*------------add star user------------------------------------------------------------------------*/
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
starBtnClick(value){
|
268
|
-
|
269
|
-
this.addStar(value)
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
addStar(uid) {
|
276
|
-
|
277
|
-
const myUserId = this.state.userId
|
278
|
-
|
279
|
-
const starUserData = uid
|
280
|
-
|
281
|
-
var add = true
|
282
|
-
|
283
|
-
const self = this
|
284
|
-
|
285
|
-
firebase.database().ref('users/' + uid + '/userStar').transaction(function(count) {
|
286
|
-
|
287
|
-
if(count){
|
288
|
-
|
289
|
-
if(count.stars&&count.stars[myUserId]){
|
290
|
-
|
291
|
-
count.starCount--;
|
292
|
-
|
293
|
-
count.stars[myUserId] = null
|
294
|
-
|
295
|
-
add = false
|
296
|
-
|
297
|
-
}else{
|
298
|
-
|
299
|
-
count.starCount++
|
300
|
-
|
301
|
-
if (!count.stars) {
|
302
|
-
|
303
|
-
count.stars = {};
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
count.stars[myUserId] = true
|
308
|
-
|
309
|
-
add = true
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
}
|
314
|
-
|
315
|
-
return count
|
316
|
-
|
317
|
-
}).then(function (result) {
|
318
|
-
|
319
|
-
if (result.snapshot) {
|
320
|
-
|
321
|
-
const updatedUser = result.snapshot.val()
|
322
|
-
|
323
|
-
for(var i = 0 ; i<self.state.search_users.length ; i++){
|
324
|
-
|
325
|
-
if(self.state.search_users[i].uid===uid){
|
326
|
-
|
327
|
-
const newSearchUsers = update(self.state.search_users, {
|
328
|
-
|
329
|
-
[i]: {userStar: {$set: updatedUser} }
|
330
|
-
|
331
|
-
})
|
332
|
-
|
333
|
-
self.setState({search_users: newSearchUsers})
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
}
|
340
|
-
|
341
|
-
}).then(function(){
|
342
|
-
|
343
|
-
if(add){
|
344
|
-
|
345
|
-
return firebase.database().ref('/users/' + myUserId + '/starred_users/').push().set({
|
346
|
-
|
347
|
-
starUserData
|
348
|
-
|
349
|
-
})
|
350
|
-
|
351
|
-
}else{
|
352
|
-
|
353
|
-
return firebase.database().ref('/users/' + myUserId + '/starred_users/').orderByChild('starUserData').equalTo(starUserData).once("value", function (snapshot) {
|
354
|
-
|
355
|
-
snapshot.forEach(function (child) {
|
356
|
-
|
357
|
-
child.ref.remove()
|
358
|
-
|
359
|
-
})
|
360
|
-
|
361
|
-
})
|
362
|
-
|
363
|
-
}
|
364
|
-
|
365
|
-
})
|
366
|
-
|
367
|
-
}
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
handleChange_Tab = (value) => {
|
388
|
-
|
389
|
-
this.setState({
|
390
|
-
|
391
|
-
tabValue: value,
|
392
|
-
|
393
|
-
});
|
394
|
-
|
395
|
-
};
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
render () {
|
402
|
-
|
403
|
-
return (
|
404
|
-
|
405
|
-
<div>
|
406
|
-
|
407
|
-
<div
|
408
|
-
|
409
|
-
style={{
|
410
|
-
|
411
|
-
backgroundColor: '',
|
412
|
-
|
413
|
-
}}
|
414
|
-
|
415
|
-
>
|
416
|
-
|
417
|
-
<div className='col s12 m4'
|
418
|
-
|
419
|
-
style={{
|
420
|
-
|
421
|
-
width: '30%',
|
422
|
-
|
423
|
-
margin: 'auto',
|
424
|
-
|
425
|
-
}}
|
426
|
-
|
427
|
-
>
|
428
|
-
|
429
|
-
<TextField
|
430
|
-
|
431
|
-
id="search"
|
432
|
-
|
433
|
-
floatingLabelText="type username for search"
|
434
|
-
|
435
|
-
value={this.state.search}
|
436
|
-
|
437
|
-
onChange={this.handleChange_search}
|
438
|
-
|
439
|
-
/>
|
440
|
-
|
441
|
-
<RaisedButton
|
442
|
-
|
443
|
-
label="Search"
|
444
|
-
|
445
|
-
secondary={true}
|
446
|
-
|
447
|
-
onClick={this.handleSearch}
|
448
|
-
|
449
|
-
/>
|
450
|
-
|
451
|
-
</div>
|
452
|
-
|
453
|
-
</div>
|
454
|
-
|
455
|
-
<div>
|
456
|
-
|
457
|
-
<div
|
458
|
-
|
459
|
-
style={{
|
460
|
-
|
461
|
-
overflowX: 'scroll'
|
462
|
-
|
463
|
-
}}
|
464
|
-
|
465
|
-
>
|
466
|
-
|
467
|
-
<div
|
468
|
-
|
469
|
-
style={{
|
470
|
-
|
471
|
-
display: 'inline-block',
|
472
|
-
|
473
|
-
whiteSpace: 'nowrap',
|
474
|
-
|
475
|
-
}}
|
476
|
-
|
477
|
-
>
|
478
|
-
|
479
|
-
{
|
480
|
-
|
481
|
-
this.state.searchReference === '0'
|
482
|
-
|
483
|
-
? <div><h>here is search reference view</h></div>
|
484
|
-
|
485
|
-
:<ul>{
|
486
|
-
|
487
|
-
this.state.search_users.map(
|
488
|
-
|
489
|
-
function(searchRef){
|
490
|
-
|
491
|
-
const self = this
|
492
|
-
|
493
|
-
return(
|
494
|
-
|
495
|
-
<li
|
496
|
-
|
497
|
-
style={{
|
498
|
-
|
499
|
-
width: '35%',
|
500
|
-
|
501
|
-
margin: 'auto',
|
502
|
-
|
503
|
-
display: 'inline-block',
|
504
|
-
|
505
|
-
marginRight:'10px',
|
506
|
-
|
507
|
-
}}
|
508
|
-
|
509
|
-
>
|
510
|
-
|
511
|
-
<Card>
|
512
|
-
|
513
|
-
<CardHeader
|
514
|
-
|
515
|
-
title={searchRef.user}
|
516
|
-
|
517
|
-
subtitle={" star:(" + searchRef.userStar.starCount + ")"}
|
518
|
-
|
519
|
-
avatar=""
|
520
|
-
|
521
|
-
/>
|
522
|
-
|
523
|
-
<CardTitle title={searchRef.title} />
|
524
|
-
|
525
|
-
<CardText>
|
526
|
-
|
527
|
-
{searchRef.explain}
|
528
|
-
|
529
|
-
</CardText>
|
530
|
-
|
531
|
-
<CardActions>
|
532
|
-
|
533
|
-
{
|
534
|
-
|
535
|
-
(searchRef.userStar.stars && searchRef.userStar.stars[self.state.userId])
|
536
|
-
|
537
|
-
?<FlatButton
|
538
|
-
|
539
|
-
backgroundColor="#FDD835"
|
540
|
-
|
541
|
-
hoverColor="#8AA62F"
|
542
|
-
|
543
|
-
label="STARRED"
|
544
|
-
|
545
|
-
onClick={() => this.starBtnClick(searchRef.uid)} />
|
546
|
-
|
547
|
-
:<FlatButton
|
548
|
-
|
549
|
-
label="STAR"
|
550
|
-
|
551
|
-
backgroundColor="#EOEOEO"
|
552
|
-
|
553
|
-
onClick={() => this.starBtnClick(searchRef.uid)} />
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
</CardActions>
|
558
|
-
|
559
|
-
</Card>
|
560
|
-
|
561
|
-
</li>
|
562
|
-
|
563
|
-
)
|
564
|
-
|
565
|
-
}.bind(this)
|
566
|
-
|
567
|
-
)
|
568
|
-
|
569
|
-
}</ul>
|
570
|
-
|
571
|
-
}
|
572
|
-
|
573
|
-
</div>
|
574
|
-
|
575
|
-
</div>
|
576
|
-
|
577
|
-
</div>
|
578
|
-
|
579
|
-
<div>
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
<Tabs
|
586
|
-
|
587
|
-
value={this.state.tabValue}
|
588
|
-
|
589
|
-
onChange={this.handleChange_Tab}
|
590
|
-
|
591
|
-
>
|
592
|
-
|
593
|
-
<Tab label="Stared users" value="a">
|
594
|
-
|
595
|
-
<div className='container'
|
596
|
-
|
597
|
-
style={{
|
598
|
-
|
599
|
-
overflowX: 'scroll',
|
600
|
-
|
601
|
-
}}
|
602
|
-
|
603
|
-
>
|
604
|
-
|
605
|
-
<div
|
606
|
-
|
607
|
-
style={{
|
608
|
-
|
609
|
-
display: 'inline-block',
|
610
|
-
|
611
|
-
whiteSpace: 'nowrap',
|
612
|
-
|
613
|
-
}}>
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
{
|
618
|
-
|
619
|
-
this.state.starred_posts.length === 0
|
620
|
-
|
621
|
-
? <div><h>There is no starred user</h></div>
|
622
|
-
|
623
|
-
: <ul>{
|
624
|
-
|
625
|
-
this.state.starred_posts.slice().map(
|
626
|
-
|
627
|
-
function(starred_post){
|
628
|
-
|
629
|
-
return(
|
630
|
-
|
631
|
-
<StarredRefCard starredPost={starred_post} />
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
)
|
636
|
-
|
637
|
-
}
|
638
|
-
|
639
|
-
)
|
640
|
-
|
641
|
-
}</ul>
|
642
|
-
|
643
|
-
}
|
644
|
-
|
645
|
-
</div>
|
646
|
-
|
647
|
-
</div>
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
</Tab>
|
658
|
-
|
659
|
-
|
660
|
-
|
661
43
|
|
662
44
|
|
663
45
|
```
|
664
|
-
|
665
|
-
![イメージ説明](4ba8a359d20610a7d8934a0d95aca2e9.png)
|
666
46
|
|
667
47
|
ホームのビューの簡単なところを作成しました。return内はmypageのコピペも多いので、まだまだ間違いあると思います。
|
668
48
|
|
@@ -688,7 +68,9 @@
|
|
688
68
|
|
689
69
|
|
690
70
|
|
691
|
-
![
|
71
|
+
![コメント開かない状態](961c7316f1ec0b9731fe8ab2c5a9d483.png)
|
72
|
+
|
73
|
+
![コメント開いた状態](dd10a29835891dc9da4f86443c12defd.png)
|
692
74
|
|
693
75
|
|
694
76
|
|
54
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,135 +40,533 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
|
43
|
+
/*------------refer starred user-------------------------------------------------------------------*/
|
44
|
-
|
44
|
+
|
45
|
+
|
46
|
+
|
45
|
-
c
|
47
|
+
fetchStarredUser(onchange) {
|
48
|
+
|
46
|
-
|
49
|
+
const self1 = this
|
50
|
+
|
51
|
+
const myUserId = self1.state.userId
|
52
|
+
|
53
|
+
var onValueChange1 = firebase.database().ref('/users/' + myUserId + '/starred_users').on('value', function(snapshot) {
|
54
|
+
|
47
|
-
const
|
55
|
+
const starred_users = [];
|
56
|
+
|
48
|
-
|
57
|
+
snapshot.forEach(function(childSnapshot) {
|
58
|
+
|
59
|
+
starred_users.push(childSnapshot.val().starUserData)
|
60
|
+
|
61
|
+
})
|
62
|
+
|
63
|
+
self1.setState({
|
64
|
+
|
65
|
+
starred_users: starred_users
|
66
|
+
|
49
|
-
|
67
|
+
}, function() {
|
68
|
+
|
50
|
-
|
69
|
+
if (onchange) onchange();
|
70
|
+
|
71
|
+
});
|
72
|
+
|
73
|
+
});
|
74
|
+
|
51
|
-
|
75
|
+
this.setState({
|
76
|
+
|
77
|
+
off_starred_user: onValueChange1
|
78
|
+
|
79
|
+
})
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
fetchStarredUserPosts() {
|
86
|
+
|
87
|
+
const self2 = this
|
88
|
+
|
89
|
+
const posts = [];
|
90
|
+
|
91
|
+
const stateStarredUsers = this.state.starred_users
|
92
|
+
|
93
|
+
for (var i = 0; i < stateStarredUsers.length; i++) {
|
94
|
+
|
95
|
+
const starredUser = stateStarredUsers[i]
|
96
|
+
|
97
|
+
firebase.database().ref('/users/' + starredUser + '/user_posts/').limitToFirst(1).once('value', function(snapshot) {
|
98
|
+
|
99
|
+
snapshot.forEach(function(childSnapshot) {
|
100
|
+
|
101
|
+
posts.push(childSnapshot.val())
|
102
|
+
|
103
|
+
self2.setState({
|
104
|
+
|
105
|
+
starred_posts: posts
|
106
|
+
|
107
|
+
});
|
108
|
+
|
109
|
+
})
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
fetchAllStarUser() {
|
120
|
+
|
121
|
+
const self = this
|
122
|
+
|
123
|
+
this.fetchStarredUser(function() {
|
124
|
+
|
125
|
+
self.fetchStarredUserPosts()
|
126
|
+
|
127
|
+
})
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
/*------------comment function open------------------------------------------------------------------------*/
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
commentFncOpen(uid,postId){
|
142
|
+
|
143
|
+
this.setState({
|
144
|
+
|
145
|
+
commentForm:true,
|
146
|
+
|
147
|
+
comment_uid:uid,
|
148
|
+
|
149
|
+
commentPostId:postId
|
150
|
+
|
151
|
+
})
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
/*------------life cicle method--------------------------------------------------------------------*/
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
componentWillMount(){
|
52
166
|
|
53
167
|
}
|
54
168
|
|
55
169
|
|
56
170
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
retu
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
st
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
171
|
+
componentDidMount(){
|
172
|
+
|
173
|
+
const self=this
|
174
|
+
|
175
|
+
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
176
|
+
|
177
|
+
if(user){
|
178
|
+
|
179
|
+
self.setState({
|
180
|
+
|
181
|
+
userId : firebase.auth().currentUser.uid
|
182
|
+
|
183
|
+
},self.fetchAllStarUser);
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
else {
|
188
|
+
|
189
|
+
self.props.history.push('/login')
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
})
|
194
|
+
|
195
|
+
this.setState({unsub});
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
componentWillUnmount() {
|
202
|
+
|
203
|
+
const self = this
|
204
|
+
|
205
|
+
this.state.unsub();
|
206
|
+
|
207
|
+
firebase.database().ref('/users/'+this.state.userId+'/starred_users/').off('value', self.state.off)
|
208
|
+
|
209
|
+
};
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
/*------------search reference method--------------------------------------------------------------*/
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
handleChange_search = (event) => {
|
218
|
+
|
219
|
+
this.setState({
|
220
|
+
|
221
|
+
search: event.target.value,
|
222
|
+
|
223
|
+
});
|
224
|
+
|
225
|
+
};
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
handleSearch = (event) =>{
|
230
|
+
|
231
|
+
const self = this
|
232
|
+
|
233
|
+
firebase.database().ref('/users/').orderByChild('user').startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value").then(function(snapshot) {
|
234
|
+
|
235
|
+
const search_users =[]
|
236
|
+
|
237
|
+
snapshot.forEach(function(childSnapshot) {
|
238
|
+
|
239
|
+
search_users.push(childSnapshot.val())
|
240
|
+
|
241
|
+
})
|
242
|
+
|
243
|
+
self.setState({
|
244
|
+
|
245
|
+
search_users:search_users,
|
246
|
+
|
247
|
+
});
|
248
|
+
|
249
|
+
})
|
250
|
+
|
251
|
+
this.setState({searchReference:'1'});
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
/*------------add star user------------------------------------------------------------------------*/
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
starBtnClick(value){
|
268
|
+
|
269
|
+
this.addStar(value)
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
addStar(uid) {
|
276
|
+
|
277
|
+
const myUserId = this.state.userId
|
278
|
+
|
279
|
+
const starUserData = uid
|
280
|
+
|
281
|
+
var add = true
|
282
|
+
|
283
|
+
const self = this
|
284
|
+
|
285
|
+
firebase.database().ref('users/' + uid + '/userStar').transaction(function(count) {
|
286
|
+
|
287
|
+
if(count){
|
288
|
+
|
289
|
+
if(count.stars&&count.stars[myUserId]){
|
290
|
+
|
291
|
+
count.starCount--;
|
292
|
+
|
293
|
+
count.stars[myUserId] = null
|
294
|
+
|
295
|
+
add = false
|
296
|
+
|
297
|
+
}else{
|
298
|
+
|
299
|
+
count.starCount++
|
300
|
+
|
301
|
+
if (!count.stars) {
|
302
|
+
|
303
|
+
count.stars = {};
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
count.stars[myUserId] = true
|
308
|
+
|
309
|
+
add = true
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
return count
|
316
|
+
|
317
|
+
}).then(function (result) {
|
318
|
+
|
319
|
+
if (result.snapshot) {
|
320
|
+
|
321
|
+
const updatedUser = result.snapshot.val()
|
322
|
+
|
323
|
+
for(var i = 0 ; i<self.state.search_users.length ; i++){
|
324
|
+
|
325
|
+
if(self.state.search_users[i].uid===uid){
|
326
|
+
|
327
|
+
const newSearchUsers = update(self.state.search_users, {
|
328
|
+
|
329
|
+
[i]: {userStar: {$set: updatedUser} }
|
330
|
+
|
331
|
+
})
|
332
|
+
|
333
|
+
self.setState({search_users: newSearchUsers})
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
}).then(function(){
|
342
|
+
|
343
|
+
if(add){
|
344
|
+
|
345
|
+
return firebase.database().ref('/users/' + myUserId + '/starred_users/').push().set({
|
346
|
+
|
347
|
+
starUserData
|
348
|
+
|
349
|
+
})
|
350
|
+
|
351
|
+
}else{
|
352
|
+
|
353
|
+
return firebase.database().ref('/users/' + myUserId + '/starred_users/').orderByChild('starUserData').equalTo(starUserData).once("value", function (snapshot) {
|
354
|
+
|
355
|
+
snapshot.forEach(function (child) {
|
356
|
+
|
357
|
+
child.ref.remove()
|
358
|
+
|
359
|
+
})
|
360
|
+
|
361
|
+
})
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
})
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
handleChange_Tab = (value) => {
|
388
|
+
|
389
|
+
this.setState({
|
390
|
+
|
391
|
+
tabValue: value,
|
392
|
+
|
393
|
+
});
|
394
|
+
|
395
|
+
};
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
render () {
|
402
|
+
|
403
|
+
return (
|
404
|
+
|
405
|
+
<div>
|
406
|
+
|
407
|
+
<div
|
408
|
+
|
409
|
+
style={{
|
410
|
+
|
411
|
+
backgroundColor: '',
|
412
|
+
|
413
|
+
}}
|
414
|
+
|
415
|
+
>
|
416
|
+
|
417
|
+
<div className='col s12 m4'
|
418
|
+
|
419
|
+
style={{
|
420
|
+
|
421
|
+
width: '30%',
|
422
|
+
|
423
|
+
margin: 'auto',
|
424
|
+
|
425
|
+
}}
|
426
|
+
|
427
|
+
>
|
428
|
+
|
429
|
+
<TextField
|
430
|
+
|
431
|
+
id="search"
|
432
|
+
|
433
|
+
floatingLabelText="type username for search"
|
434
|
+
|
435
|
+
value={this.state.search}
|
436
|
+
|
437
|
+
onChange={this.handleChange_search}
|
438
|
+
|
439
|
+
/>
|
440
|
+
|
441
|
+
<RaisedButton
|
442
|
+
|
443
|
+
label="Search"
|
444
|
+
|
445
|
+
secondary={true}
|
446
|
+
|
447
|
+
onClick={this.handleSearch}
|
448
|
+
|
449
|
+
/>
|
450
|
+
|
451
|
+
</div>
|
452
|
+
|
453
|
+
</div>
|
454
|
+
|
455
|
+
<div>
|
456
|
+
|
457
|
+
<div
|
458
|
+
|
459
|
+
style={{
|
460
|
+
|
461
|
+
overflowX: 'scroll'
|
462
|
+
|
463
|
+
}}
|
464
|
+
|
465
|
+
>
|
466
|
+
|
467
|
+
<div
|
468
|
+
|
469
|
+
style={{
|
470
|
+
|
471
|
+
display: 'inline-block',
|
472
|
+
|
473
|
+
whiteSpace: 'nowrap',
|
474
|
+
|
475
|
+
}}
|
476
|
+
|
477
|
+
>
|
478
|
+
|
479
|
+
{
|
480
|
+
|
481
|
+
this.state.searchReference === '0'
|
482
|
+
|
483
|
+
? <div><h>here is search reference view</h></div>
|
484
|
+
|
485
|
+
:<ul>{
|
486
|
+
|
487
|
+
this.state.search_users.map(
|
488
|
+
|
489
|
+
function(searchRef){
|
490
|
+
|
491
|
+
const self = this
|
492
|
+
|
493
|
+
return(
|
494
|
+
|
495
|
+
<li
|
92
496
|
|
93
497
|
style={{
|
94
498
|
|
95
|
-
width: '
|
499
|
+
width: '35%',
|
500
|
+
|
501
|
+
margin: 'auto',
|
96
502
|
|
97
503
|
display: 'inline-block',
|
98
504
|
|
99
|
-
margin:'
|
505
|
+
marginRight:'10px',
|
100
506
|
|
101
507
|
}}
|
102
508
|
|
103
509
|
>
|
104
510
|
|
105
|
-
<Card
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
<
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
s
|
140
|
-
|
141
|
-
t
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
/>
|
160
|
-
|
161
|
-
</List>
|
162
|
-
|
163
|
-
</Card>
|
511
|
+
<Card>
|
512
|
+
|
513
|
+
<CardHeader
|
514
|
+
|
515
|
+
title={searchRef.user}
|
516
|
+
|
517
|
+
subtitle={" star:(" + searchRef.userStar.starCount + ")"}
|
518
|
+
|
519
|
+
avatar=""
|
520
|
+
|
521
|
+
/>
|
522
|
+
|
523
|
+
<CardTitle title={searchRef.title} />
|
524
|
+
|
525
|
+
<CardText>
|
526
|
+
|
527
|
+
{searchRef.explain}
|
528
|
+
|
529
|
+
</CardText>
|
530
|
+
|
531
|
+
<CardActions>
|
532
|
+
|
533
|
+
{
|
534
|
+
|
535
|
+
(searchRef.userStar.stars && searchRef.userStar.stars[self.state.userId])
|
536
|
+
|
537
|
+
?<FlatButton
|
538
|
+
|
539
|
+
backgroundColor="#FDD835"
|
540
|
+
|
541
|
+
hoverColor="#8AA62F"
|
542
|
+
|
543
|
+
label="STARRED"
|
544
|
+
|
545
|
+
onClick={() => this.starBtnClick(searchRef.uid)} />
|
546
|
+
|
547
|
+
:<FlatButton
|
548
|
+
|
549
|
+
label="STAR"
|
550
|
+
|
551
|
+
backgroundColor="#EOEOEO"
|
552
|
+
|
553
|
+
onClick={() => this.starBtnClick(searchRef.uid)} />
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
</CardActions>
|
558
|
+
|
559
|
+
</Card>
|
560
|
+
|
561
|
+
</li>
|
164
562
|
|
165
563
|
)
|
166
564
|
|
167
565
|
}.bind(this)
|
168
566
|
|
169
|
-
)
|
567
|
+
)
|
170
|
-
|
568
|
+
|
171
|
-
}</ul>
|
569
|
+
}</ul>
|
172
570
|
|
173
571
|
}
|
174
572
|
|
@@ -176,17 +574,95 @@
|
|
176
574
|
|
177
575
|
</div>
|
178
576
|
|
577
|
+
</div>
|
578
|
+
|
579
|
+
<div>
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
<Tabs
|
586
|
+
|
587
|
+
value={this.state.tabValue}
|
588
|
+
|
589
|
+
onChange={this.handleChange_Tab}
|
590
|
+
|
591
|
+
>
|
592
|
+
|
593
|
+
<Tab label="Stared users" value="a">
|
594
|
+
|
595
|
+
<div className='container'
|
596
|
+
|
597
|
+
style={{
|
598
|
+
|
599
|
+
overflowX: 'scroll',
|
600
|
+
|
179
|
-
|
601
|
+
}}
|
602
|
+
|
180
|
-
|
603
|
+
>
|
604
|
+
|
181
|
-
|
605
|
+
<div
|
606
|
+
|
182
|
-
|
607
|
+
style={{
|
608
|
+
|
609
|
+
display: 'inline-block',
|
610
|
+
|
611
|
+
whiteSpace: 'nowrap',
|
612
|
+
|
613
|
+
}}>
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
{
|
618
|
+
|
619
|
+
this.state.starred_posts.length === 0
|
620
|
+
|
621
|
+
? <div><h>There is no starred user</h></div>
|
622
|
+
|
623
|
+
: <ul>{
|
624
|
+
|
625
|
+
this.state.starred_posts.slice().map(
|
626
|
+
|
627
|
+
function(starred_post){
|
628
|
+
|
629
|
+
return(
|
630
|
+
|
631
|
+
<StarredRefCard starredPost={starred_post} />
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
)
|
636
|
+
|
183
|
-
}
|
637
|
+
}
|
638
|
+
|
184
|
-
|
639
|
+
)
|
640
|
+
|
185
|
-
|
641
|
+
}</ul>
|
642
|
+
|
643
|
+
}
|
644
|
+
|
645
|
+
</div>
|
646
|
+
|
647
|
+
</div>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
</Tab>
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
186
662
|
|
187
663
|
```
|
188
664
|
|
189
|
-
|
665
|
+
![イメージ説明](4ba8a359d20610a7d8934a0d95aca2e9.png)
|
190
666
|
|
191
667
|
ホームのビューの簡単なところを作成しました。return内はmypageのコピペも多いので、まだまだ間違いあると思います。
|
192
668
|
|
53
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -212,4 +212,8 @@
|
|
212
212
|
|
213
213
|
|
214
214
|
|
215
|
+
![イメージ説明](a79434ba3430c9f6d5e8a23fa3be0c08.png)
|
216
|
+
|
217
|
+
|
218
|
+
|
215
219
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
52
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,9 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
+
|
44
|
+
|
43
|
-
class
|
45
|
+
class starredRefCard extends Component {
|
44
46
|
|
45
47
|
constructor(props) {
|
46
48
|
|
@@ -48,585 +50,139 @@
|
|
48
50
|
|
49
51
|
this.state = {
|
50
52
|
|
51
|
-
unsub:'',
|
52
|
-
|
53
|
-
search:'',
|
54
|
-
|
55
|
-
searchReference:'0',
|
56
|
-
|
57
|
-
tabValue:'a',
|
58
|
-
|
59
|
-
starBtnShown:'1',
|
60
|
-
|
61
|
-
off_starred_user:'',
|
62
|
-
|
63
|
-
off_starred_user_posts:'',
|
64
|
-
|
65
|
-
willStarUser:'',
|
66
|
-
|
67
|
-
userId:'',
|
68
|
-
|
69
|
-
starCount:'',
|
70
|
-
|
71
|
-
search_users : [],
|
72
|
-
|
73
|
-
starred_users : [],
|
74
|
-
|
75
|
-
starred_posts : [],
|
76
|
-
|
77
|
-
latest_posts : [],
|
78
|
-
|
79
53
|
}
|
80
54
|
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
render(){
|
60
|
+
|
61
|
+
return(
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<div
|
66
|
+
|
67
|
+
style={{
|
68
|
+
|
69
|
+
display: 'inline-block',
|
70
|
+
|
71
|
+
whiteSpace: 'nowrap',
|
72
|
+
|
73
|
+
}}>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
props.length === 0
|
80
|
+
|
81
|
+
? <div><h>There is no starred user</h></div>
|
82
|
+
|
83
|
+
: <ul>{
|
84
|
+
|
85
|
+
props.slice().map(
|
86
|
+
|
87
|
+
function(starred_user){
|
88
|
+
|
89
|
+
return(
|
90
|
+
|
91
|
+
<Card
|
92
|
+
|
93
|
+
style={{
|
94
|
+
|
95
|
+
width: '100%',
|
96
|
+
|
97
|
+
display: 'inline-block',
|
98
|
+
|
99
|
+
margin:'auto'
|
100
|
+
|
101
|
+
}}
|
102
|
+
|
103
|
+
>
|
104
|
+
|
105
|
+
<CardHeader
|
106
|
+
|
107
|
+
title={starred_user.author}
|
108
|
+
|
109
|
+
avatar=""
|
110
|
+
|
111
|
+
/>
|
112
|
+
|
113
|
+
<CardTitle title={starred_user.title} subtitle={" star:(" + starred_user.postStar.starCount + ")"} />
|
114
|
+
|
115
|
+
<CardText>
|
116
|
+
|
117
|
+
{starred_user.body}
|
118
|
+
|
119
|
+
</CardText>
|
120
|
+
|
121
|
+
<CardActions>
|
122
|
+
|
123
|
+
<FlatButton
|
124
|
+
|
125
|
+
secondary
|
126
|
+
|
127
|
+
label="Comment"
|
128
|
+
|
129
|
+
onClick={() => this.commentFncOpen(starred_user.uid,starred_user.postId)} />
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
</CardActions>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<CardHeader
|
138
|
+
|
139
|
+
showExpandableButton
|
140
|
+
|
141
|
+
title="Comments" />
|
142
|
+
|
143
|
+
<List expandable>
|
144
|
+
|
145
|
+
<p>--------------------------------------</p>
|
146
|
+
|
147
|
+
<ListItem
|
148
|
+
|
149
|
+
leftAvatar={<Avatar src='' />}
|
150
|
+
|
151
|
+
primaryText="Author"
|
152
|
+
|
153
|
+
secondaryText={
|
154
|
+
|
155
|
+
<p>Hello</p>
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
/>
|
160
|
+
|
161
|
+
</List>
|
162
|
+
|
163
|
+
</Card>
|
164
|
+
|
165
|
+
)
|
166
|
+
|
167
|
+
}.bind(this)
|
168
|
+
|
169
|
+
)
|
170
|
+
|
171
|
+
}</ul>
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
</div>
|
178
|
+
|
179
|
+
)}
|
180
|
+
|
181
|
+
|
182
|
+
|
81
183
|
}
|
82
184
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
/*------------refer starred user-------------------------------------------------------------------*/
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
fetchStarredUser(onchange) {
|
92
|
-
|
93
|
-
const self1 = this
|
94
|
-
|
95
|
-
const myUserId = self1.state.userId
|
96
|
-
|
97
|
-
var onValueChange1 = firebase.database().ref('/users/' + myUserId + '/starred_users').on('value', function(snapshot) {
|
98
|
-
|
99
|
-
const starred_users = [];
|
100
|
-
|
101
|
-
snapshot.forEach(function(childSnapshot) {
|
102
|
-
|
103
|
-
starred_users.push(childSnapshot.val().starUserData)
|
104
|
-
|
105
|
-
})
|
106
|
-
|
107
|
-
self1.setState({
|
108
|
-
|
109
|
-
starred_users: starred_users
|
110
|
-
|
111
|
-
}, function() {
|
112
|
-
|
113
|
-
if (onchange) onchange();
|
114
|
-
|
115
|
-
});
|
116
|
-
|
117
|
-
});
|
118
|
-
|
119
|
-
this.setState({
|
120
|
-
|
121
|
-
off_starred_user: onValueChange1
|
122
|
-
|
123
|
-
})
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
fetchStarredUserPosts() {
|
130
|
-
|
131
|
-
const self2 = this
|
132
|
-
|
133
|
-
const posts = [];
|
134
|
-
|
135
|
-
const stateStarredUsers = this.state.starred_users
|
136
|
-
|
137
|
-
for (var i = 0; i < stateStarredUsers.length; i++) {
|
138
|
-
|
139
|
-
const starredUser = stateStarredUsers[i]
|
140
|
-
|
141
|
-
firebase.database().ref('/users/' + starredUser + '/user_posts/').limitToFirst(1).once('value', function(snapshot) {
|
142
|
-
|
143
|
-
snapshot.forEach(function(childSnapshot) {
|
144
|
-
|
145
|
-
posts.push(childSnapshot.val())
|
146
|
-
|
147
|
-
self2.setState({
|
148
|
-
|
149
|
-
starred_posts: posts
|
150
|
-
|
151
|
-
});
|
152
|
-
|
153
|
-
})
|
154
|
-
|
155
|
-
});
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
fetchAllStarUser() {
|
164
|
-
|
165
|
-
const self = this
|
166
|
-
|
167
|
-
this.fetchStarredUser(function() {
|
168
|
-
|
169
|
-
self.fetchStarredUserPosts()
|
170
|
-
|
171
|
-
})
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
/*------------life cicle method--------------------------------------------------------------------*/
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
componentWillMount(){
|
182
|
-
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
componentDidMount(){
|
188
|
-
|
189
|
-
const self=this
|
190
|
-
|
191
|
-
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
192
|
-
|
193
|
-
if(user){
|
194
|
-
|
195
|
-
self.setState({
|
196
|
-
|
197
|
-
userId : firebase.auth().currentUser.uid
|
198
|
-
|
199
|
-
},self.fetchAllStarUser);
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
else {
|
204
|
-
|
205
|
-
self.props.history.push('/login')
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
})
|
210
|
-
|
211
|
-
this.setState({unsub});
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
componentWillUnmount() {
|
218
|
-
|
219
|
-
const self = this
|
220
|
-
|
221
|
-
this.state.unsub();
|
222
|
-
|
223
|
-
firebase.database().ref('/users/'+this.state.userId+'/starred_users/').off('value', self.state.off)
|
224
|
-
|
225
|
-
};
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
/*------------search reference method--------------------------------------------------------------*/
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
handleChange_search = (event) => {
|
234
|
-
|
235
|
-
this.setState({
|
236
|
-
|
237
|
-
search: event.target.value,
|
238
|
-
|
239
|
-
});
|
240
|
-
|
241
|
-
};
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
handleSearch = (event) =>{
|
246
|
-
|
247
|
-
const self = this
|
248
|
-
|
249
|
-
firebase.database().ref('/users/').orderByChild('user').startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value").then(function(snapshot) {
|
250
|
-
|
251
|
-
const search_users =[]
|
252
|
-
|
253
|
-
snapshot.forEach(function(childSnapshot) {
|
254
|
-
|
255
|
-
search_users.push(childSnapshot.val())
|
256
|
-
|
257
|
-
})
|
258
|
-
|
259
|
-
self.setState({
|
260
|
-
|
261
|
-
search_users:search_users,
|
262
|
-
|
263
|
-
});
|
264
|
-
|
265
|
-
})
|
266
|
-
|
267
|
-
this.setState({searchReference:'1'});
|
268
|
-
|
269
|
-
}
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
/*------------add star user------------------------------------------------------------------------*/
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
starBtnClick(value){
|
284
|
-
|
285
|
-
this.addStar(value)
|
286
|
-
|
287
|
-
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
addStar(uid) {
|
292
|
-
|
293
|
-
const myUserId = this.state.userId
|
294
|
-
|
295
|
-
const starUserData = uid
|
296
|
-
|
297
|
-
var add = true
|
298
|
-
|
299
|
-
firebase.database().ref('users/' + uid + '/userStar').transaction(function(count) {
|
300
|
-
|
301
|
-
if(count){
|
302
|
-
|
303
|
-
if(count.stars&&count.stars[myUserId]){
|
304
|
-
|
305
|
-
count.starCount--;
|
306
|
-
|
307
|
-
count.stars[myUserId] = null
|
308
|
-
|
309
|
-
add = false
|
310
|
-
|
311
|
-
}else{
|
312
|
-
|
313
|
-
count.starCount++
|
314
|
-
|
315
|
-
if (!count.stars) {
|
316
|
-
|
317
|
-
count.stars = {};
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
count.stars[myUserId] = true
|
322
|
-
|
323
|
-
add = true
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
return count
|
330
|
-
|
331
|
-
}).then(function(){
|
332
|
-
|
333
|
-
if(add){
|
334
|
-
|
335
|
-
return firebase.database().ref('/users/' + myUserId + '/starred_users/').push().set({
|
336
|
-
|
337
|
-
starUserData
|
338
|
-
|
339
|
-
})
|
340
|
-
|
341
|
-
}else{
|
342
|
-
|
343
|
-
return firebase.database().ref('/users/' + myUserId + '/starred_users/').orderByChild('starUserData').startAt(starUserData).remove()
|
344
|
-
|
345
|
-
}
|
346
|
-
|
347
|
-
})
|
348
|
-
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
/*------------Tab control------------------------------------------------------------------------*/
|
358
|
-
|
359
|
-
handleChange_Tab = (value) => {
|
360
|
-
|
361
|
-
this.setState({
|
362
|
-
|
363
|
-
tabValue: value,
|
364
|
-
|
365
|
-
});
|
366
|
-
|
367
|
-
};
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
render () {
|
374
|
-
|
375
|
-
return (
|
376
|
-
|
377
|
-
<div>
|
378
|
-
|
379
|
-
<div className='col s12 m4'>
|
380
|
-
|
381
|
-
<Card>
|
382
|
-
|
383
|
-
<CardText>
|
384
|
-
|
385
|
-
<TextField
|
386
|
-
|
387
|
-
id="search"
|
388
|
-
|
389
|
-
floatingLabelText="type username for search"
|
390
|
-
|
391
|
-
value={this.state.search}
|
392
|
-
|
393
|
-
onChange={this.handleChange_search}
|
394
|
-
|
395
|
-
/>
|
396
|
-
|
397
|
-
<RaisedButton
|
398
|
-
|
399
|
-
label="Search"
|
400
|
-
|
401
|
-
secondary={true}
|
402
|
-
|
403
|
-
onClick={this.handleSearch}
|
404
|
-
|
405
|
-
/>
|
406
|
-
|
407
|
-
</CardText>
|
408
|
-
|
409
|
-
</Card>
|
410
|
-
|
411
|
-
</div>
|
412
|
-
|
413
|
-
<div>
|
414
|
-
|
415
|
-
{
|
416
|
-
|
417
|
-
this.state.searchReference === '0'
|
418
|
-
|
419
|
-
? <div><h>here is search reference view</h></div>
|
420
|
-
|
421
|
-
:<ul>{
|
422
|
-
|
423
|
-
this.state.search_users.map(
|
424
|
-
|
425
|
-
function(searchRef){
|
426
|
-
|
427
|
-
return(
|
428
|
-
|
429
|
-
<div className='col s12 m4'>
|
430
|
-
|
431
|
-
<Card>
|
432
|
-
|
433
|
-
<CardTitle title={searchRef.user} subtitle={searchRef.title} />
|
434
|
-
|
435
|
-
<CardText>
|
436
|
-
|
437
|
-
{searchRef.explain}
|
438
|
-
|
439
|
-
</CardText>
|
440
|
-
|
441
|
-
<CardActions>
|
442
|
-
|
443
|
-
<FlatButton
|
444
|
-
|
445
|
-
backgroundColor="#a4c639"
|
446
|
-
|
447
|
-
hoverColor="#8AA62F"
|
448
|
-
|
449
|
-
label="STAR"
|
450
|
-
|
451
|
-
onClick={() => this.starBtnClick(searchRef.uid)}
|
452
|
-
|
453
|
-
value={searchRef.uid} />
|
454
|
-
|
455
|
-
</CardActions>
|
456
|
-
|
457
|
-
</Card>
|
458
|
-
|
459
|
-
</div>
|
460
|
-
|
461
|
-
)
|
462
|
-
|
463
|
-
}.bind(this)
|
464
|
-
|
465
|
-
)
|
466
|
-
|
467
|
-
}</ul>
|
468
|
-
|
469
|
-
}
|
470
|
-
|
471
|
-
</div>
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
<Tabs
|
478
|
-
|
479
|
-
value={this.state.tabValue}
|
480
|
-
|
481
|
-
onChange={this.handleChange_Tab}
|
482
|
-
|
483
|
-
>
|
484
|
-
|
485
|
-
<Tab label="Stared users" value="a">
|
486
|
-
|
487
|
-
<div className='container'>
|
488
|
-
|
489
|
-
<div>
|
490
|
-
|
491
|
-
{
|
492
|
-
|
493
|
-
this.state.starred_users.length === 0
|
494
|
-
|
495
|
-
? <div><h>There is no starred user</h></div>
|
496
|
-
|
497
|
-
: <ul>{
|
498
|
-
|
499
|
-
this.state.starred_posts.slice().map(
|
500
|
-
|
501
|
-
function(starred_user){
|
502
|
-
|
503
|
-
return(
|
504
|
-
|
505
|
-
<div className='col s12 m4'>
|
506
|
-
|
507
|
-
<Card>
|
508
|
-
|
509
|
-
<CardTitle title={starred_user.title} subtitle={starred_user.author+ " star:"+starred_user.starCount} />
|
510
|
-
|
511
|
-
<CardText>
|
512
|
-
|
513
|
-
{starred_user.body}
|
514
|
-
|
515
|
-
</CardText>
|
516
|
-
|
517
|
-
<CardActions>
|
518
|
-
|
519
|
-
<FlatButton secondary label="Comment" />
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
</CardActions>
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
<CardHeader
|
528
|
-
|
529
|
-
showExpandableButton
|
530
|
-
|
531
|
-
title="Comments" />
|
532
|
-
|
533
|
-
<List expandable>
|
534
|
-
|
535
|
-
<ListItem>
|
536
|
-
|
537
|
-
<h3>John</h3>
|
538
|
-
|
539
|
-
<p>post.title post.author + post.starCount</p>
|
540
|
-
|
541
|
-
</ListItem>
|
542
|
-
|
543
|
-
<ListItem>
|
544
|
-
|
545
|
-
<h3>Mary</h3>
|
546
|
-
|
547
|
-
<p>what a bad day</p>
|
548
|
-
|
549
|
-
</ListItem>
|
550
|
-
|
551
|
-
</List>
|
552
|
-
|
553
|
-
</Card>
|
554
|
-
|
555
|
-
</div>
|
556
|
-
|
557
|
-
)
|
558
|
-
|
559
|
-
}
|
560
|
-
|
561
|
-
)
|
562
|
-
|
563
|
-
}</ul>
|
564
|
-
|
565
|
-
}
|
566
|
-
|
567
|
-
</div>
|
568
|
-
|
569
|
-
</div>
|
570
|
-
|
571
|
-
</Tab>
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
<Tab label="latest posted users" value="b">
|
576
|
-
|
577
|
-
<div>
|
578
|
-
|
579
|
-
<ul>{
|
580
|
-
|
581
|
-
this.state.starred_posts.slice().reverse().map(
|
582
|
-
|
583
|
-
function(latest_post){
|
584
|
-
|
585
|
-
return(
|
586
|
-
|
587
|
-
<div className='col s12 m4'>
|
588
|
-
|
589
|
-
<Card>
|
590
|
-
|
591
|
-
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
592
|
-
|
593
|
-
<CardText>
|
594
|
-
|
595
|
-
{latest_post.body}
|
596
|
-
|
597
|
-
</CardText>
|
598
|
-
|
599
|
-
</Card>
|
600
|
-
|
601
|
-
</div>
|
602
|
-
|
603
|
-
)
|
604
|
-
|
605
|
-
}
|
606
|
-
|
607
|
-
)
|
608
|
-
|
609
|
-
}</ul>
|
610
|
-
|
611
|
-
</div>
|
612
|
-
|
613
|
-
</Tab>
|
614
|
-
|
615
|
-
</Tabs>
|
616
|
-
|
617
|
-
</div>
|
618
|
-
|
619
|
-
)
|
620
|
-
|
621
|
-
}
|
622
|
-
|
623
|
-
}
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
export default
|
185
|
+
export default starredRefCard
|
628
|
-
|
629
|
-
|
630
186
|
|
631
187
|
```
|
632
188
|
|
@@ -638,7 +194,7 @@
|
|
638
194
|
|
639
195
|
今後ホームに実装する機能として、
|
640
196
|
|
641
|
-
|
197
|
+
❎スターをつけたユーザーのカードを表示し、そこには最新のユーザーの記事を載せていきます。
|
642
198
|
|
643
199
|
❎ユーザーの検索機能。 だいたい目測はついた。
|
644
200
|
|
@@ -650,4 +206,10 @@
|
|
650
206
|
|
651
207
|
|
652
208
|
|
209
|
+
|
210
|
+
|
211
|
+
現在、機能分割中です。
|
212
|
+
|
213
|
+
|
214
|
+
|
653
215
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
51
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,6 +66,8 @@
|
|
66
66
|
|
67
67
|
userId:'',
|
68
68
|
|
69
|
+
starCount:'',
|
70
|
+
|
69
71
|
search_users : [],
|
70
72
|
|
71
73
|
starred_users : [],
|
@@ -98,7 +100,7 @@
|
|
98
100
|
|
99
101
|
snapshot.forEach(function(childSnapshot) {
|
100
102
|
|
101
|
-
starred_users.push(childSnapshot.val())
|
103
|
+
starred_users.push(childSnapshot.val().starUserData)
|
102
104
|
|
103
105
|
})
|
104
106
|
|
@@ -278,328 +280,350 @@
|
|
278
280
|
|
279
281
|
|
280
282
|
|
281
|
-
starBtnClick
|
283
|
+
starBtnClick(value){
|
282
|
-
|
284
|
+
|
283
|
-
|
285
|
+
this.addStar(value)
|
284
|
-
|
285
|
-
this.setState({willStarUser:value},this.allAddFunction)
|
286
286
|
|
287
287
|
}
|
288
288
|
|
289
289
|
|
290
290
|
|
291
|
-
addStar
|
291
|
+
addStar(uid) {
|
292
292
|
|
293
293
|
const myUserId = this.state.userId
|
294
294
|
|
295
|
-
|
296
|
-
|
297
|
-
var
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
n
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
295
|
+
const starUserData = uid
|
296
|
+
|
297
|
+
var add = true
|
298
|
+
|
299
|
+
firebase.database().ref('users/' + uid + '/userStar').transaction(function(count) {
|
300
|
+
|
301
|
+
if(count){
|
302
|
+
|
303
|
+
if(count.stars&&count.stars[myUserId]){
|
304
|
+
|
305
|
+
count.starCount--;
|
306
|
+
|
307
|
+
count.stars[myUserId] = null
|
308
|
+
|
309
|
+
add = false
|
310
|
+
|
311
|
+
}else{
|
312
|
+
|
313
|
+
count.starCount++
|
314
|
+
|
315
|
+
if (!count.stars) {
|
316
|
+
|
317
|
+
count.stars = {};
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
count.stars[myUserId] = true
|
322
|
+
|
323
|
+
add = true
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
return count
|
330
|
+
|
331
|
+
}).then(function(){
|
332
|
+
|
333
|
+
if(add){
|
334
|
+
|
335
|
+
return firebase.database().ref('/users/' + myUserId + '/starred_users/').push().set({
|
336
|
+
|
337
|
+
starUserData
|
338
|
+
|
339
|
+
})
|
340
|
+
|
341
|
+
}else{
|
342
|
+
|
343
|
+
return firebase.database().ref('/users/' + myUserId + '/starred_users/').orderByChild('starUserData').startAt(starUserData).remove()
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
})
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
/*------------Tab control------------------------------------------------------------------------*/
|
358
|
+
|
359
|
+
handleChange_Tab = (value) => {
|
360
|
+
|
361
|
+
this.setState({
|
362
|
+
|
363
|
+
tabValue: value,
|
364
|
+
|
365
|
+
});
|
366
|
+
|
367
|
+
};
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
render () {
|
374
|
+
|
375
|
+
return (
|
376
|
+
|
377
|
+
<div>
|
378
|
+
|
379
|
+
<div className='col s12 m4'>
|
380
|
+
|
381
|
+
<Card>
|
382
|
+
|
383
|
+
<CardText>
|
384
|
+
|
385
|
+
<TextField
|
386
|
+
|
387
|
+
id="search"
|
388
|
+
|
389
|
+
floatingLabelText="type username for search"
|
390
|
+
|
391
|
+
value={this.state.search}
|
392
|
+
|
393
|
+
onChange={this.handleChange_search}
|
394
|
+
|
395
|
+
/>
|
396
|
+
|
397
|
+
<RaisedButton
|
398
|
+
|
399
|
+
label="Search"
|
400
|
+
|
401
|
+
secondary={true}
|
402
|
+
|
403
|
+
onClick={this.handleSearch}
|
404
|
+
|
405
|
+
/>
|
406
|
+
|
407
|
+
</CardText>
|
408
|
+
|
409
|
+
</Card>
|
410
|
+
|
411
|
+
</div>
|
412
|
+
|
413
|
+
<div>
|
414
|
+
|
415
|
+
{
|
416
|
+
|
417
|
+
this.state.searchReference === '0'
|
418
|
+
|
419
|
+
? <div><h>here is search reference view</h></div>
|
420
|
+
|
421
|
+
:<ul>{
|
422
|
+
|
423
|
+
this.state.search_users.map(
|
424
|
+
|
425
|
+
function(searchRef){
|
426
|
+
|
427
|
+
return(
|
428
|
+
|
429
|
+
<div className='col s12 m4'>
|
430
|
+
|
431
|
+
<Card>
|
432
|
+
|
433
|
+
<CardTitle title={searchRef.user} subtitle={searchRef.title} />
|
434
|
+
|
435
|
+
<CardText>
|
436
|
+
|
437
|
+
{searchRef.explain}
|
438
|
+
|
439
|
+
</CardText>
|
440
|
+
|
441
|
+
<CardActions>
|
442
|
+
|
443
|
+
<FlatButton
|
444
|
+
|
445
|
+
backgroundColor="#a4c639"
|
446
|
+
|
447
|
+
hoverColor="#8AA62F"
|
448
|
+
|
449
|
+
label="STAR"
|
450
|
+
|
451
|
+
onClick={() => this.starBtnClick(searchRef.uid)}
|
452
|
+
|
453
|
+
value={searchRef.uid} />
|
454
|
+
|
455
|
+
</CardActions>
|
456
|
+
|
457
|
+
</Card>
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
)
|
462
|
+
|
463
|
+
}.bind(this)
|
464
|
+
|
465
|
+
)
|
466
|
+
|
467
|
+
}</ul>
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
</div>
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
<Tabs
|
478
|
+
|
479
|
+
value={this.state.tabValue}
|
480
|
+
|
481
|
+
onChange={this.handleChange_Tab}
|
482
|
+
|
483
|
+
>
|
484
|
+
|
485
|
+
<Tab label="Stared users" value="a">
|
486
|
+
|
487
|
+
<div className='container'>
|
488
|
+
|
489
|
+
<div>
|
490
|
+
|
491
|
+
{
|
492
|
+
|
493
|
+
this.state.starred_users.length === 0
|
494
|
+
|
495
|
+
? <div><h>There is no starred user</h></div>
|
496
|
+
|
497
|
+
: <ul>{
|
498
|
+
|
499
|
+
this.state.starred_posts.slice().map(
|
500
|
+
|
501
|
+
function(starred_user){
|
502
|
+
|
503
|
+
return(
|
504
|
+
|
505
|
+
<div className='col s12 m4'>
|
506
|
+
|
507
|
+
<Card>
|
508
|
+
|
509
|
+
<CardTitle title={starred_user.title} subtitle={starred_user.author+ " star:"+starred_user.starCount} />
|
510
|
+
|
511
|
+
<CardText>
|
512
|
+
|
513
|
+
{starred_user.body}
|
514
|
+
|
515
|
+
</CardText>
|
516
|
+
|
517
|
+
<CardActions>
|
518
|
+
|
519
|
+
<FlatButton secondary label="Comment" />
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
</CardActions>
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
<CardHeader
|
528
|
+
|
529
|
+
showExpandableButton
|
530
|
+
|
531
|
+
title="Comments" />
|
532
|
+
|
533
|
+
<List expandable>
|
534
|
+
|
535
|
+
<ListItem>
|
536
|
+
|
537
|
+
<h3>John</h3>
|
538
|
+
|
539
|
+
<p>post.title post.author + post.starCount</p>
|
540
|
+
|
541
|
+
</ListItem>
|
542
|
+
|
543
|
+
<ListItem>
|
544
|
+
|
545
|
+
<h3>Mary</h3>
|
546
|
+
|
547
|
+
<p>what a bad day</p>
|
548
|
+
|
549
|
+
</ListItem>
|
550
|
+
|
551
|
+
</List>
|
552
|
+
|
553
|
+
</Card>
|
554
|
+
|
555
|
+
</div>
|
556
|
+
|
557
|
+
)
|
558
|
+
|
559
|
+
}
|
560
|
+
|
561
|
+
)
|
562
|
+
|
563
|
+
}</ul>
|
564
|
+
|
565
|
+
}
|
566
|
+
|
567
|
+
</div>
|
568
|
+
|
569
|
+
</div>
|
570
|
+
|
571
|
+
</Tab>
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
<Tab label="latest posted users" value="b">
|
576
|
+
|
577
|
+
<div>
|
578
|
+
|
579
|
+
<ul>{
|
580
|
+
|
581
|
+
this.state.starred_posts.slice().reverse().map(
|
582
|
+
|
583
|
+
function(latest_post){
|
584
|
+
|
585
|
+
return(
|
586
|
+
|
587
|
+
<div className='col s12 m4'>
|
588
|
+
|
589
|
+
<Card>
|
590
|
+
|
591
|
+
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
592
|
+
|
593
|
+
<CardText>
|
594
|
+
|
595
|
+
{latest_post.body}
|
596
|
+
|
597
|
+
</CardText>
|
598
|
+
|
599
|
+
</Card>
|
600
|
+
|
601
|
+
</div>
|
602
|
+
|
603
|
+
)
|
604
|
+
|
605
|
+
}
|
606
|
+
|
607
|
+
)
|
608
|
+
|
609
|
+
}</ul>
|
610
|
+
|
611
|
+
</div>
|
612
|
+
|
613
|
+
</Tab>
|
614
|
+
|
615
|
+
</Tabs>
|
616
|
+
|
617
|
+
</div>
|
618
|
+
|
619
|
+
)
|
620
|
+
|
621
|
+
}
|
308
622
|
|
309
623
|
}
|
310
624
|
|
311
625
|
|
312
626
|
|
313
|
-
resetWillStarUser(){
|
314
|
-
|
315
|
-
this.setState({
|
316
|
-
|
317
|
-
willStarUser:''
|
318
|
-
|
319
|
-
});
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
allAddFunction(){
|
326
|
-
|
327
|
-
const self = this
|
328
|
-
|
329
|
-
this.addStarUserToDataBase(function() {
|
330
|
-
|
331
|
-
self.resetWillStarUser()
|
332
|
-
|
333
|
-
})
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
/*------------Tab control------------------------------------------------------------------------*/
|
342
|
-
|
343
|
-
handleChange_Tab = (value) => {
|
344
|
-
|
345
|
-
this.setState({
|
346
|
-
|
347
|
-
tabValue: value,
|
348
|
-
|
349
|
-
});
|
350
|
-
|
351
|
-
};
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
render () {
|
358
|
-
|
359
|
-
return (
|
360
|
-
|
361
|
-
<div>
|
362
|
-
|
363
|
-
<div className='col s12 m4'>
|
364
|
-
|
365
|
-
<Card>
|
366
|
-
|
367
|
-
<CardText>
|
368
|
-
|
369
|
-
<TextField
|
370
|
-
|
371
|
-
id="search"
|
372
|
-
|
373
|
-
floatingLabelText="type username for search"
|
374
|
-
|
375
|
-
value={this.state.search}
|
376
|
-
|
377
|
-
onChange={this.handleChange_search}
|
378
|
-
|
379
|
-
/>
|
380
|
-
|
381
|
-
<RaisedButton
|
382
|
-
|
383
|
-
label="Search"
|
384
|
-
|
385
|
-
secondary={true}
|
386
|
-
|
387
|
-
onClick={this.handleSearch}
|
388
|
-
|
389
|
-
/>
|
390
|
-
|
391
|
-
</CardText>
|
392
|
-
|
393
|
-
</Card>
|
394
|
-
|
395
|
-
</div>
|
396
|
-
|
397
|
-
<div>
|
398
|
-
|
399
|
-
{
|
400
|
-
|
401
|
-
this.state.searchReference === '0'
|
402
|
-
|
403
|
-
? <div><h>here is search reference view</h></div>
|
404
|
-
|
405
|
-
:<ul>{
|
406
|
-
|
407
|
-
this.state.search_users.map(
|
408
|
-
|
409
|
-
function(searchRef){
|
410
|
-
|
411
|
-
const self = this
|
412
|
-
|
413
|
-
return(
|
414
|
-
|
415
|
-
<div className='col s12 m4'>
|
416
|
-
|
417
|
-
<Card>
|
418
|
-
|
419
|
-
<CardTitle title={searchRef.user} subtitle={searchRef.title} />
|
420
|
-
|
421
|
-
<CardText>
|
422
|
-
|
423
|
-
{searchRef.explain}
|
424
|
-
|
425
|
-
</CardText>
|
426
|
-
|
427
|
-
<CardActions>
|
428
|
-
|
429
|
-
<FlatButton primary label="STAR" onClick={this.starBtnClick} value={searchRef.uid} />
|
430
|
-
|
431
|
-
</CardActions>
|
432
|
-
|
433
|
-
</Card>
|
434
|
-
|
435
|
-
</div>
|
436
|
-
|
437
|
-
)
|
438
|
-
|
439
|
-
}.bind(this)
|
440
|
-
|
441
|
-
)
|
442
|
-
|
443
|
-
}</ul>
|
444
|
-
|
445
|
-
}
|
446
|
-
|
447
|
-
</div>
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
<Tabs
|
454
|
-
|
455
|
-
value={this.state.tabValue}
|
456
|
-
|
457
|
-
onChange={this.handleChange_Tab}
|
458
|
-
|
459
|
-
>
|
460
|
-
|
461
|
-
<Tab label="Stared users" value="a">
|
462
|
-
|
463
|
-
<div className='container'>
|
464
|
-
|
465
|
-
<div>
|
466
|
-
|
467
|
-
{
|
468
|
-
|
469
|
-
this.state.starred_users.length === 0
|
470
|
-
|
471
|
-
? <div><h>There is no starred user</h></div>
|
472
|
-
|
473
|
-
: <ul>{
|
474
|
-
|
475
|
-
this.state.starred_posts.slice().map(
|
476
|
-
|
477
|
-
function(starred_user){
|
478
|
-
|
479
|
-
return(
|
480
|
-
|
481
|
-
<div className='col s12 m4'>
|
482
|
-
|
483
|
-
<Card>
|
484
|
-
|
485
|
-
<CardTitle title={starred_user.title} subtitle={starred_user.author+ " star:"+starred_user.starCount} />
|
486
|
-
|
487
|
-
<CardText>
|
488
|
-
|
489
|
-
{starred_user.body}
|
490
|
-
|
491
|
-
</CardText>
|
492
|
-
|
493
|
-
<CardActions>
|
494
|
-
|
495
|
-
<FlatButton secondary label="Comment" />
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
</CardActions>
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
<CardHeader
|
504
|
-
|
505
|
-
showExpandableButton
|
506
|
-
|
507
|
-
title="Comments" />
|
508
|
-
|
509
|
-
<List expandable>
|
510
|
-
|
511
|
-
<ListItem>
|
512
|
-
|
513
|
-
<h3>John</h3>
|
514
|
-
|
515
|
-
<p>post.title post.author + post.starCount</p>
|
516
|
-
|
517
|
-
</ListItem>
|
518
|
-
|
519
|
-
<ListItem>
|
520
|
-
|
521
|
-
<h3>Mary</h3>
|
522
|
-
|
523
|
-
<p>what a bad day</p>
|
524
|
-
|
525
|
-
</ListItem>
|
526
|
-
|
527
|
-
</List>
|
528
|
-
|
529
|
-
</Card>
|
530
|
-
|
531
|
-
</div>
|
532
|
-
|
533
|
-
)
|
534
|
-
|
535
|
-
}
|
536
|
-
|
537
|
-
)
|
538
|
-
|
539
|
-
}</ul>
|
540
|
-
|
541
|
-
}
|
542
|
-
|
543
|
-
</div>
|
544
|
-
|
545
|
-
</div>
|
546
|
-
|
547
|
-
</Tab>
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
<Tab label="latest posted users" value="b">
|
552
|
-
|
553
|
-
<div>
|
554
|
-
|
555
|
-
<ul>{
|
556
|
-
|
557
|
-
this.state.starred_posts.slice().reverse().map(
|
558
|
-
|
559
|
-
function(latest_post){
|
560
|
-
|
561
|
-
return(
|
562
|
-
|
563
|
-
<div className='col s12 m4'>
|
564
|
-
|
565
|
-
<Card>
|
566
|
-
|
567
|
-
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
568
|
-
|
569
|
-
<CardText>
|
570
|
-
|
571
|
-
{latest_post.body}
|
572
|
-
|
573
|
-
</CardText>
|
574
|
-
|
575
|
-
</Card>
|
576
|
-
|
577
|
-
</div>
|
578
|
-
|
579
|
-
)
|
580
|
-
|
581
|
-
}
|
582
|
-
|
583
|
-
)
|
584
|
-
|
585
|
-
}</ul>
|
586
|
-
|
587
|
-
</div>
|
588
|
-
|
589
|
-
</Tab>
|
590
|
-
|
591
|
-
</Tabs>
|
592
|
-
|
593
|
-
</div>
|
594
|
-
|
595
|
-
)
|
596
|
-
|
597
|
-
}
|
598
|
-
|
599
|
-
}
|
600
|
-
|
601
|
-
|
602
|
-
|
603
627
|
export default Home
|
604
628
|
|
605
629
|
|
50
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,15 +56,23 @@
|
|
56
56
|
|
57
57
|
tabValue:'a',
|
58
58
|
|
59
|
+
starBtnShown:'1',
|
60
|
+
|
59
|
-
off_stared_user:'',
|
61
|
+
off_starred_user:'',
|
60
|
-
|
62
|
+
|
61
|
-
off_stared_user_posts:'',
|
63
|
+
off_starred_user_posts:'',
|
64
|
+
|
65
|
+
willStarUser:'',
|
62
66
|
|
63
67
|
userId:'',
|
64
68
|
|
69
|
+
search_users : [],
|
70
|
+
|
65
|
-
stared_users: [],
|
71
|
+
starred_users : [],
|
72
|
+
|
66
|
-
|
73
|
+
starred_posts : [],
|
74
|
+
|
67
|
-
posts: []
|
75
|
+
latest_posts : [],
|
68
76
|
|
69
77
|
}
|
70
78
|
|
@@ -72,356 +80,530 @@
|
|
72
80
|
|
73
81
|
|
74
82
|
|
83
|
+
|
84
|
+
|
85
|
+
/*------------refer starred user-------------------------------------------------------------------*/
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
fetchStarredUser(onchange) {
|
90
|
+
|
91
|
+
const self1 = this
|
92
|
+
|
93
|
+
const myUserId = self1.state.userId
|
94
|
+
|
95
|
+
var onValueChange1 = firebase.database().ref('/users/' + myUserId + '/starred_users').on('value', function(snapshot) {
|
96
|
+
|
97
|
+
const starred_users = [];
|
98
|
+
|
99
|
+
snapshot.forEach(function(childSnapshot) {
|
100
|
+
|
101
|
+
starred_users.push(childSnapshot.val())
|
102
|
+
|
103
|
+
})
|
104
|
+
|
105
|
+
self1.setState({
|
106
|
+
|
107
|
+
starred_users: starred_users
|
108
|
+
|
109
|
+
}, function() {
|
110
|
+
|
111
|
+
if (onchange) onchange();
|
112
|
+
|
113
|
+
});
|
114
|
+
|
115
|
+
});
|
116
|
+
|
117
|
+
this.setState({
|
118
|
+
|
119
|
+
off_starred_user: onValueChange1
|
120
|
+
|
121
|
+
})
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
fetchStarredUserPosts() {
|
128
|
+
|
129
|
+
const self2 = this
|
130
|
+
|
131
|
+
const posts = [];
|
132
|
+
|
133
|
+
const stateStarredUsers = this.state.starred_users
|
134
|
+
|
135
|
+
for (var i = 0; i < stateStarredUsers.length; i++) {
|
136
|
+
|
137
|
+
const starredUser = stateStarredUsers[i]
|
138
|
+
|
139
|
+
firebase.database().ref('/users/' + starredUser + '/user_posts/').limitToFirst(1).once('value', function(snapshot) {
|
140
|
+
|
141
|
+
snapshot.forEach(function(childSnapshot) {
|
142
|
+
|
143
|
+
posts.push(childSnapshot.val())
|
144
|
+
|
145
|
+
self2.setState({
|
146
|
+
|
147
|
+
starred_posts: posts
|
148
|
+
|
149
|
+
});
|
150
|
+
|
151
|
+
})
|
152
|
+
|
153
|
+
});
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
|
75
|
-
|
161
|
+
fetchAllStarUser() {
|
76
|
-
|
162
|
+
|
77
|
-
|
163
|
+
const self = this
|
78
|
-
|
164
|
+
|
79
|
-
|
165
|
+
this.fetchStarredUser(function() {
|
80
|
-
|
81
|
-
|
166
|
+
|
82
|
-
|
83
|
-
|
167
|
+
self.fetchStarredUserPosts()
|
84
|
-
|
85
|
-
|
168
|
+
|
86
|
-
|
87
|
-
stared_users.push(childSnapshot.val())
|
88
|
-
|
89
|
-
|
169
|
+
})
|
90
|
-
|
91
|
-
|
170
|
+
|
92
|
-
|
93
|
-
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
94
|
-
|
175
|
+
/*------------life cicle method--------------------------------------------------------------------*/
|
176
|
+
|
177
|
+
|
178
|
+
|
95
|
-
|
179
|
+
componentWillMount(){
|
96
180
|
|
97
181
|
}
|
98
182
|
|
99
183
|
|
100
184
|
|
101
|
-
|
102
|
-
|
103
|
-
const self
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
185
|
+
componentDidMount(){
|
186
|
+
|
187
|
+
const self=this
|
188
|
+
|
189
|
+
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
190
|
+
|
191
|
+
if(user){
|
192
|
+
|
193
|
+
self.setState({
|
194
|
+
|
195
|
+
userId : firebase.auth().currentUser.uid
|
196
|
+
|
197
|
+
},self.fetchAllStarUser);
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
else {
|
202
|
+
|
203
|
+
self.props.history.push('/login')
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
})
|
208
|
+
|
209
|
+
this.setState({unsub});
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
componentWillUnmount() {
|
216
|
+
|
217
|
+
const self = this
|
218
|
+
|
219
|
+
this.state.unsub();
|
220
|
+
|
221
|
+
firebase.database().ref('/users/'+this.state.userId+'/starred_users/').off('value', self.state.off)
|
222
|
+
|
223
|
+
};
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
/*------------search reference method--------------------------------------------------------------*/
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
handleChange_search = (event) => {
|
232
|
+
|
233
|
+
this.setState({
|
234
|
+
|
235
|
+
search: event.target.value,
|
236
|
+
|
237
|
+
});
|
238
|
+
|
239
|
+
};
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
handleSearch = (event) =>{
|
244
|
+
|
245
|
+
const self = this
|
246
|
+
|
247
|
+
firebase.database().ref('/users/').orderByChild('user').startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value").then(function(snapshot) {
|
248
|
+
|
249
|
+
const search_users =[]
|
250
|
+
|
251
|
+
snapshot.forEach(function(childSnapshot) {
|
252
|
+
|
253
|
+
search_users.push(childSnapshot.val())
|
254
|
+
|
255
|
+
})
|
256
|
+
|
257
|
+
self.setState({
|
258
|
+
|
259
|
+
search_users:search_users,
|
260
|
+
|
261
|
+
});
|
262
|
+
|
263
|
+
})
|
264
|
+
|
265
|
+
this.setState({searchReference:'1'});
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
/*------------add star user------------------------------------------------------------------------*/
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
starBtnClick = (value) =>{
|
282
|
+
|
283
|
+
const self = this
|
284
|
+
|
285
|
+
this.setState({willStarUser:value},this.allAddFunction)
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
addStarUserToDataBase() {
|
292
|
+
|
293
|
+
const myUserId = this.state.userId
|
294
|
+
|
295
|
+
var starUserData = this.state.willStarUser;
|
296
|
+
|
297
|
+
var newStarUserRef = firebase.database().ref('/users/' + myUserId + '/starred_users/').push()
|
298
|
+
|
299
|
+
var path = newStarUserRef.toString()
|
300
|
+
|
301
|
+
newStarUserRef.set({
|
302
|
+
|
303
|
+
path:starUserData
|
304
|
+
|
305
|
+
})
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
resetWillStarUser(){
|
314
|
+
|
315
|
+
this.setState({
|
316
|
+
|
317
|
+
willStarUser:''
|
318
|
+
|
319
|
+
});
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
allAddFunction(){
|
326
|
+
|
327
|
+
const self = this
|
328
|
+
|
329
|
+
this.addStarUserToDataBase(function() {
|
330
|
+
|
331
|
+
self.resetWillStarUser()
|
332
|
+
|
333
|
+
})
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
/*------------Tab control------------------------------------------------------------------------*/
|
342
|
+
|
343
|
+
handleChange_Tab = (value) => {
|
344
|
+
|
345
|
+
this.setState({
|
346
|
+
|
347
|
+
tabValue: value,
|
348
|
+
|
349
|
+
});
|
350
|
+
|
351
|
+
};
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
render () {
|
358
|
+
|
359
|
+
return (
|
360
|
+
|
361
|
+
<div>
|
362
|
+
|
363
|
+
<div className='col s12 m4'>
|
364
|
+
|
365
|
+
<Card>
|
366
|
+
|
367
|
+
<CardText>
|
368
|
+
|
369
|
+
<TextField
|
370
|
+
|
371
|
+
id="search"
|
372
|
+
|
373
|
+
floatingLabelText="type username for search"
|
374
|
+
|
375
|
+
value={this.state.search}
|
376
|
+
|
377
|
+
onChange={this.handleChange_search}
|
378
|
+
|
379
|
+
/>
|
380
|
+
|
381
|
+
<RaisedButton
|
382
|
+
|
383
|
+
label="Search"
|
384
|
+
|
385
|
+
secondary={true}
|
386
|
+
|
387
|
+
onClick={this.handleSearch}
|
388
|
+
|
389
|
+
/>
|
390
|
+
|
391
|
+
</CardText>
|
392
|
+
|
393
|
+
</Card>
|
394
|
+
|
395
|
+
</div>
|
396
|
+
|
397
|
+
<div>
|
398
|
+
|
399
|
+
{
|
400
|
+
|
401
|
+
this.state.searchReference === '0'
|
402
|
+
|
403
|
+
? <div><h>here is search reference view</h></div>
|
404
|
+
|
405
|
+
:<ul>{
|
406
|
+
|
407
|
+
this.state.search_users.map(
|
408
|
+
|
409
|
+
function(searchRef){
|
410
|
+
|
411
|
+
const self = this
|
412
|
+
|
413
|
+
return(
|
414
|
+
|
415
|
+
<div className='col s12 m4'>
|
416
|
+
|
417
|
+
<Card>
|
418
|
+
|
419
|
+
<CardTitle title={searchRef.user} subtitle={searchRef.title} />
|
420
|
+
|
421
|
+
<CardText>
|
422
|
+
|
423
|
+
{searchRef.explain}
|
424
|
+
|
425
|
+
</CardText>
|
426
|
+
|
427
|
+
<CardActions>
|
428
|
+
|
429
|
+
<FlatButton primary label="STAR" onClick={this.starBtnClick} value={searchRef.uid} />
|
430
|
+
|
431
|
+
</CardActions>
|
432
|
+
|
433
|
+
</Card>
|
434
|
+
|
435
|
+
</div>
|
436
|
+
|
437
|
+
)
|
438
|
+
|
439
|
+
}.bind(this)
|
440
|
+
|
441
|
+
)
|
442
|
+
|
443
|
+
}</ul>
|
124
444
|
|
125
445
|
}
|
126
446
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
va
|
136
|
-
|
137
|
-
i
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
447
|
+
</div>
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
<Tabs
|
454
|
+
|
455
|
+
value={this.state.tabValue}
|
456
|
+
|
457
|
+
onChange={this.handleChange_Tab}
|
458
|
+
|
459
|
+
>
|
460
|
+
|
461
|
+
<Tab label="Stared users" value="a">
|
462
|
+
|
463
|
+
<div className='container'>
|
464
|
+
|
465
|
+
<div>
|
466
|
+
|
467
|
+
{
|
468
|
+
|
469
|
+
this.state.starred_users.length === 0
|
470
|
+
|
471
|
+
? <div><h>There is no starred user</h></div>
|
472
|
+
|
473
|
+
: <ul>{
|
474
|
+
|
475
|
+
this.state.starred_posts.slice().map(
|
476
|
+
|
477
|
+
function(starred_user){
|
478
|
+
|
479
|
+
return(
|
480
|
+
|
481
|
+
<div className='col s12 m4'>
|
482
|
+
|
483
|
+
<Card>
|
484
|
+
|
485
|
+
<CardTitle title={starred_user.title} subtitle={starred_user.author+ " star:"+starred_user.starCount} />
|
486
|
+
|
487
|
+
<CardText>
|
488
|
+
|
489
|
+
{starred_user.body}
|
490
|
+
|
491
|
+
</CardText>
|
492
|
+
|
493
|
+
<CardActions>
|
494
|
+
|
495
|
+
<FlatButton secondary label="Comment" />
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
</CardActions>
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
<CardHeader
|
504
|
+
|
505
|
+
showExpandableButton
|
506
|
+
|
507
|
+
title="Comments" />
|
508
|
+
|
509
|
+
<List expandable>
|
510
|
+
|
511
|
+
<ListItem>
|
512
|
+
|
513
|
+
<h3>John</h3>
|
514
|
+
|
515
|
+
<p>post.title post.author + post.starCount</p>
|
516
|
+
|
517
|
+
</ListItem>
|
518
|
+
|
519
|
+
<ListItem>
|
520
|
+
|
521
|
+
<h3>Mary</h3>
|
522
|
+
|
523
|
+
<p>what a bad day</p>
|
524
|
+
|
525
|
+
</ListItem>
|
526
|
+
|
527
|
+
</List>
|
528
|
+
|
529
|
+
</Card>
|
530
|
+
|
531
|
+
</div>
|
532
|
+
|
533
|
+
)
|
534
|
+
|
535
|
+
}
|
536
|
+
|
537
|
+
)
|
538
|
+
|
539
|
+
}</ul>
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
</div>
|
544
|
+
|
545
|
+
</div>
|
546
|
+
|
547
|
+
</Tab>
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
<Tab label="latest posted users" value="b">
|
552
|
+
|
553
|
+
<div>
|
554
|
+
|
555
|
+
<ul>{
|
556
|
+
|
557
|
+
this.state.starred_posts.slice().reverse().map(
|
558
|
+
|
559
|
+
function(latest_post){
|
560
|
+
|
561
|
+
return(
|
562
|
+
|
563
|
+
<div className='col s12 m4'>
|
564
|
+
|
565
|
+
<Card>
|
566
|
+
|
567
|
+
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
568
|
+
|
569
|
+
<CardText>
|
570
|
+
|
571
|
+
{latest_post.body}
|
572
|
+
|
573
|
+
</CardText>
|
574
|
+
|
575
|
+
</Card>
|
576
|
+
|
577
|
+
</div>
|
578
|
+
|
579
|
+
)
|
146
580
|
|
147
581
|
}
|
148
582
|
|
149
|
-
else {
|
150
|
-
|
151
|
-
self.props.history.push('/login')
|
152
|
-
|
153
|
-
}
|
154
|
-
|
155
|
-
|
583
|
+
)
|
156
|
-
|
584
|
+
|
157
|
-
|
585
|
+
}</ul>
|
158
|
-
|
159
|
-
|
586
|
+
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
587
|
+
</div>
|
588
|
+
|
164
|
-
|
589
|
+
</Tab>
|
590
|
+
|
165
|
-
|
591
|
+
</Tabs>
|
592
|
+
|
593
|
+
</div>
|
594
|
+
|
595
|
+
)
|
166
596
|
|
167
597
|
}
|
168
598
|
|
169
|
-
|
170
|
-
|
171
|
-
componentWillUnmount() {
|
172
|
-
|
173
|
-
const self = this
|
174
|
-
|
175
|
-
this.state.unsub();
|
176
|
-
|
177
|
-
firebase.database().ref('/users/'+this.state.userId+'/stared_users/').off('value', self.state.off)
|
178
|
-
|
179
|
-
};
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
handleChange_search = (event) => {
|
184
|
-
|
185
|
-
this.setState({
|
186
|
-
|
187
|
-
search: event.target.value,
|
188
|
-
|
189
|
-
});
|
190
|
-
|
191
|
-
};
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
handleSearch = (event) =>{
|
196
|
-
|
197
|
-
const self = this
|
198
|
-
|
199
|
-
firebase.database().ref().startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value")
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
this.setState({searchReference:'1'});
|
204
|
-
|
205
|
-
};
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
handleChange_Tab = (value) => {
|
210
|
-
|
211
|
-
this.setState({
|
212
|
-
|
213
|
-
tabValue: value,
|
214
|
-
|
215
|
-
});
|
216
|
-
|
217
|
-
};
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
render () {
|
224
|
-
|
225
|
-
return (
|
226
|
-
|
227
|
-
<div>
|
228
|
-
|
229
|
-
<div className='col s12 m4'>
|
230
|
-
|
231
|
-
<Card>
|
232
|
-
|
233
|
-
<CardText>
|
234
|
-
|
235
|
-
<TextField
|
236
|
-
|
237
|
-
id="search"
|
238
|
-
|
239
|
-
floatingLabelText="type username for search"
|
240
|
-
|
241
|
-
value={this.state.search}
|
242
|
-
|
243
|
-
onChange={this.handleChange_search}
|
244
|
-
|
245
|
-
/>
|
246
|
-
|
247
|
-
<RaisedButton
|
248
|
-
|
249
|
-
label="Search"
|
250
|
-
|
251
|
-
secondary={true}
|
252
|
-
|
253
|
-
onClick={this.handleSearch}
|
254
|
-
|
255
|
-
/>
|
256
|
-
|
257
|
-
</CardText>
|
258
|
-
|
259
|
-
</Card>
|
260
|
-
|
261
|
-
</div>
|
262
|
-
|
263
|
-
<div>
|
264
|
-
|
265
|
-
{
|
266
|
-
|
267
|
-
this.state.searchReference === '0'
|
268
|
-
|
269
|
-
? <div><h>There is no such user</h></div>
|
270
|
-
|
271
|
-
:<ul>{
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
<div className='col s12 m4'>
|
278
|
-
|
279
|
-
<Card>
|
280
|
-
|
281
|
-
<CardTitle title='you can open this' subtitle='game master' />
|
282
|
-
|
283
|
-
<CardText>
|
284
|
-
|
285
|
-
congra
|
286
|
-
|
287
|
-
</CardText>
|
288
|
-
|
289
|
-
</Card>
|
290
|
-
|
291
|
-
</div>
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
</ul>
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
</div>
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
<Tabs
|
310
|
-
|
311
|
-
value={this.state.tabValue}
|
312
|
-
|
313
|
-
onChange={this.handleChange_Tab}
|
314
|
-
|
315
|
-
>
|
316
|
-
|
317
|
-
<Tab label="Stared users" value="a">
|
318
|
-
|
319
|
-
<div className='container'>
|
320
|
-
|
321
|
-
<div>
|
322
|
-
|
323
|
-
{
|
324
|
-
|
325
|
-
this.state.stared_users.length === 0
|
326
|
-
|
327
|
-
? <div><h>There is no stared user</h></div>
|
328
|
-
|
329
|
-
: <ul>{
|
330
|
-
|
331
|
-
this.state.posts.slice().reverse().map(
|
332
|
-
|
333
|
-
function(stared_user){
|
334
|
-
|
335
|
-
return(
|
336
|
-
|
337
|
-
<div className='col s12 m4'>
|
338
|
-
|
339
|
-
<Card>
|
340
|
-
|
341
|
-
<CardTitle title={stared_user.title} subtitle={stared_user.author+ " star:"+stared_user.starCount} />
|
342
|
-
|
343
|
-
<CardText>
|
344
|
-
|
345
|
-
{stared_user.body}
|
346
|
-
|
347
|
-
</CardText>
|
348
|
-
|
349
|
-
</Card>
|
350
|
-
|
351
|
-
</div>
|
352
|
-
|
353
|
-
)
|
354
|
-
|
355
|
-
}
|
356
|
-
|
357
|
-
)
|
358
|
-
|
359
|
-
}</ul>
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
</div>
|
364
|
-
|
365
|
-
</div>
|
366
|
-
|
367
|
-
</Tab>
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
<Tab label="latest posted users" value="b">
|
372
|
-
|
373
|
-
<div>
|
374
|
-
|
375
|
-
<ul>{
|
376
|
-
|
377
|
-
this.state.posts.slice().reverse().map(
|
378
|
-
|
379
|
-
function(latest_post){
|
380
|
-
|
381
|
-
return(
|
382
|
-
|
383
|
-
<div className='col s12 m4'>
|
384
|
-
|
385
|
-
<Card>
|
386
|
-
|
387
|
-
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
388
|
-
|
389
|
-
<CardText>
|
390
|
-
|
391
|
-
{latest_post.body}
|
392
|
-
|
393
|
-
</CardText>
|
394
|
-
|
395
|
-
</Card>
|
396
|
-
|
397
|
-
</div>
|
398
|
-
|
399
|
-
)
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
|
-
)
|
404
|
-
|
405
|
-
}</ul>
|
406
|
-
|
407
|
-
</div>
|
408
|
-
|
409
|
-
</Tab>
|
410
|
-
|
411
|
-
</Tabs>
|
412
|
-
|
413
|
-
</div>
|
414
|
-
|
415
|
-
)
|
416
|
-
|
417
|
-
}
|
418
|
-
|
419
599
|
}
|
420
600
|
|
421
601
|
|
422
602
|
|
423
603
|
export default Home
|
424
604
|
|
605
|
+
|
606
|
+
|
425
607
|
```
|
426
608
|
|
427
609
|
|
49
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,14 +72,12 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
-
fetch
|
75
|
+
fetchStaredUser(){
|
76
76
|
|
77
77
|
const self = this
|
78
78
|
|
79
79
|
const myUserId = self.state.userId
|
80
80
|
|
81
|
-
const staredUser=self.state.stared_users
|
82
|
-
|
83
81
|
var onValueChange1 = firebase.database().ref('/users/'+myUserId+'/stared_users').on('value',function(snapshot) {
|
84
82
|
|
85
83
|
const stared_users = [];
|
@@ -96,26 +94,40 @@
|
|
96
94
|
|
97
95
|
this.setState({off_stared_user:onValueChange1})
|
98
96
|
|
99
|
-
var onValueChange2 = firebase.database().ref('/users/'+staredUser+'/user_posts/').on('value',function(snapshot) {
|
100
|
-
|
101
|
-
const posts = [];
|
102
|
-
|
103
|
-
snapshot.forEach(function(childSnapshot){
|
104
|
-
|
105
|
-
posts.push(childSnapshot.val())
|
106
|
-
|
107
|
-
})
|
108
|
-
|
109
|
-
self.setState({ posts: posts });
|
110
|
-
|
111
|
-
});
|
112
|
-
|
113
|
-
this.setState({off_stared_user_posts:onValueChange2})
|
114
|
-
|
115
97
|
}
|
116
98
|
|
117
99
|
|
118
100
|
|
101
|
+
fetchStaredUserPosts(){
|
102
|
+
|
103
|
+
const self = this
|
104
|
+
|
105
|
+
for(var i = 0 ; i < self.state.stared_users.length ; i++){
|
106
|
+
|
107
|
+
const staredUser = this.state.stared_users[i]
|
108
|
+
|
109
|
+
var onValueChange2 = firebase.database().ref('/users/' + staredUser + '/user_posts/').limitToFirst(1).on('value',function(snapshot) {
|
110
|
+
|
111
|
+
const posts = [];
|
112
|
+
|
113
|
+
snapshot.forEach(function(childSnapshot){
|
114
|
+
|
115
|
+
posts.push(childSnapshot.val())
|
116
|
+
|
117
|
+
})
|
118
|
+
|
119
|
+
self.setState({ posts: posts });
|
120
|
+
|
121
|
+
});
|
122
|
+
|
123
|
+
this.setState({off_stared_user_posts:onValueChange2})
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
119
131
|
componentWillMount(){
|
120
132
|
|
121
133
|
const self=this
|
@@ -128,9 +140,9 @@
|
|
128
140
|
|
129
141
|
userId : firebase.auth().currentUser.uid
|
130
142
|
|
131
|
-
},self.fetch
|
143
|
+
},self.fetchStaredUser);
|
144
|
+
|
132
|
-
|
145
|
+
self.fetchStaredUserPosts
|
133
|
-
|
134
146
|
|
135
147
|
}
|
136
148
|
|
@@ -410,8 +422,6 @@
|
|
410
422
|
|
411
423
|
export default Home
|
412
424
|
|
413
|
-
|
414
|
-
|
415
425
|
```
|
416
426
|
|
417
427
|
|
48
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,10 +104,10 @@
|
|
104
104
|
|
105
105
|
posts.push(childSnapshot.val())
|
106
106
|
|
107
|
-
self.setState({ posts: posts });
|
108
|
-
|
109
107
|
})
|
110
108
|
|
109
|
+
self.setState({ posts: posts });
|
110
|
+
|
111
111
|
});
|
112
112
|
|
113
113
|
this.setState({off_stared_user_posts:onValueChange2})
|
47
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,10 +88,10 @@
|
|
88
88
|
|
89
89
|
stared_users.push(childSnapshot.val())
|
90
90
|
|
91
|
-
self.setState({ stared_users: stared_users });
|
92
|
-
|
93
91
|
})
|
94
92
|
|
93
|
+
self.setState({ stared_users: stared_users });
|
94
|
+
|
95
95
|
});
|
96
96
|
|
97
97
|
this.setState({off_stared_user:onValueChange1})
|
46
更新コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,9 @@
|
|
56
56
|
|
57
57
|
tabValue:'a',
|
58
58
|
|
59
|
-
off:'',
|
59
|
+
off_stared_user:'',
|
60
|
+
|
61
|
+
off_stared_user_posts:'',
|
60
62
|
|
61
63
|
userId:'',
|
62
64
|
|
@@ -70,6 +72,50 @@
|
|
70
72
|
|
71
73
|
|
72
74
|
|
75
|
+
fetchPosts(){
|
76
|
+
|
77
|
+
const self = this
|
78
|
+
|
79
|
+
const myUserId = self.state.userId
|
80
|
+
|
81
|
+
const staredUser=self.state.stared_users
|
82
|
+
|
83
|
+
var onValueChange1 = firebase.database().ref('/users/'+myUserId+'/stared_users').on('value',function(snapshot) {
|
84
|
+
|
85
|
+
const stared_users = [];
|
86
|
+
|
87
|
+
snapshot.forEach(function(childSnapshot){
|
88
|
+
|
89
|
+
stared_users.push(childSnapshot.val())
|
90
|
+
|
91
|
+
self.setState({ stared_users: stared_users });
|
92
|
+
|
93
|
+
})
|
94
|
+
|
95
|
+
});
|
96
|
+
|
97
|
+
this.setState({off_stared_user:onValueChange1})
|
98
|
+
|
99
|
+
var onValueChange2 = firebase.database().ref('/users/'+staredUser+'/user_posts/').on('value',function(snapshot) {
|
100
|
+
|
101
|
+
const posts = [];
|
102
|
+
|
103
|
+
snapshot.forEach(function(childSnapshot){
|
104
|
+
|
105
|
+
posts.push(childSnapshot.val())
|
106
|
+
|
107
|
+
self.setState({ posts: posts });
|
108
|
+
|
109
|
+
})
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
this.setState({off_stared_user_posts:onValueChange2})
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
73
119
|
componentWillMount(){
|
74
120
|
|
75
121
|
const self=this
|
@@ -104,25 +150,7 @@
|
|
104
150
|
|
105
151
|
componentDidMount(){
|
106
152
|
|
107
|
-
|
153
|
+
|
108
|
-
|
109
|
-
const self = this
|
110
|
-
|
111
|
-
var onValueChange = firebase.database().ref('/users/'+myUserId+'/stared_users/').on('value',function(snapshot) {
|
112
|
-
|
113
|
-
const stared_users = [];
|
114
|
-
|
115
|
-
snapshot.forEach(function(childSnapshot){
|
116
|
-
|
117
|
-
stared_users.push(childSnapshot.val()),
|
118
|
-
|
119
|
-
self.setState({ stared_users: stared_users });
|
120
|
-
|
121
|
-
})
|
122
|
-
|
123
|
-
});
|
124
|
-
|
125
|
-
this.setState({off:onValueChange})
|
126
154
|
|
127
155
|
}
|
128
156
|
|
@@ -224,29 +252,25 @@
|
|
224
252
|
|
225
253
|
{
|
226
254
|
|
227
|
-
this.state.searchReference === 0
|
255
|
+
this.state.searchReference === '0'
|
228
256
|
|
229
257
|
? <div><h>There is no such user</h></div>
|
230
258
|
|
231
259
|
:<ul>{
|
232
260
|
|
233
|
-
|
261
|
+
|
234
|
-
|
235
|
-
|
262
|
+
|
236
|
-
|
237
|
-
|
263
|
+
|
238
264
|
|
239
265
|
<div className='col s12 m4'>
|
240
266
|
|
241
267
|
<Card>
|
242
268
|
|
243
|
-
<CardTitle title=
|
269
|
+
<CardTitle title='you can open this' subtitle='game master' />
|
244
270
|
|
245
271
|
<CardText>
|
246
272
|
|
247
|
-
a
|
248
|
-
|
249
|
-
|
273
|
+
congra
|
250
274
|
|
251
275
|
</CardText>
|
252
276
|
|
@@ -254,122 +278,122 @@
|
|
254
278
|
|
255
279
|
</div>
|
256
280
|
|
257
|
-
|
281
|
+
|
258
282
|
|
259
283
|
}
|
260
284
|
|
285
|
+
|
286
|
+
|
287
|
+
</ul>
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
</div>
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<Tabs
|
298
|
+
|
299
|
+
value={this.state.tabValue}
|
300
|
+
|
301
|
+
onChange={this.handleChange_Tab}
|
302
|
+
|
303
|
+
>
|
304
|
+
|
305
|
+
<Tab label="Stared users" value="a">
|
306
|
+
|
307
|
+
<div className='container'>
|
308
|
+
|
309
|
+
<div>
|
310
|
+
|
311
|
+
{
|
312
|
+
|
313
|
+
this.state.stared_users.length === 0
|
314
|
+
|
315
|
+
? <div><h>There is no stared user</h></div>
|
316
|
+
|
317
|
+
: <ul>{
|
318
|
+
|
319
|
+
this.state.posts.slice().reverse().map(
|
320
|
+
|
321
|
+
function(stared_user){
|
322
|
+
|
323
|
+
return(
|
324
|
+
|
325
|
+
<div className='col s12 m4'>
|
326
|
+
|
327
|
+
<Card>
|
328
|
+
|
329
|
+
<CardTitle title={stared_user.title} subtitle={stared_user.author+ " star:"+stared_user.starCount} />
|
330
|
+
|
331
|
+
<CardText>
|
332
|
+
|
333
|
+
{stared_user.body}
|
334
|
+
|
335
|
+
</CardText>
|
336
|
+
|
337
|
+
</Card>
|
338
|
+
|
339
|
+
</div>
|
340
|
+
|
261
341
|
)
|
262
342
|
|
343
|
+
}
|
344
|
+
|
345
|
+
)
|
346
|
+
|
263
|
-
}</ul>
|
347
|
+
}</ul>
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
</div>
|
352
|
+
|
353
|
+
</div>
|
354
|
+
|
355
|
+
</Tab>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
<Tab label="latest posted users" value="b">
|
360
|
+
|
361
|
+
<div>
|
362
|
+
|
363
|
+
<ul>{
|
364
|
+
|
365
|
+
this.state.posts.slice().reverse().map(
|
366
|
+
|
367
|
+
function(latest_post){
|
368
|
+
|
369
|
+
return(
|
370
|
+
|
371
|
+
<div className='col s12 m4'>
|
372
|
+
|
373
|
+
<Card>
|
374
|
+
|
375
|
+
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
376
|
+
|
377
|
+
<CardText>
|
378
|
+
|
379
|
+
{latest_post.body}
|
380
|
+
|
381
|
+
</CardText>
|
382
|
+
|
383
|
+
</Card>
|
384
|
+
|
385
|
+
</div>
|
386
|
+
|
387
|
+
)
|
264
388
|
|
265
389
|
}
|
266
390
|
|
391
|
+
)
|
392
|
+
|
393
|
+
}</ul>
|
394
|
+
|
267
395
|
</div>
|
268
396
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
<Tabs
|
274
|
-
|
275
|
-
value={this.state.tabValue}
|
276
|
-
|
277
|
-
onChange={this.handleChange_Tab}
|
278
|
-
|
279
|
-
>
|
280
|
-
|
281
|
-
<Tab label="Stared users" value="a">
|
282
|
-
|
283
|
-
<div className='container'>
|
284
|
-
|
285
|
-
<div>
|
286
|
-
|
287
|
-
{
|
288
|
-
|
289
|
-
this.state.stared_users.length === 0
|
290
|
-
|
291
|
-
? <div><h>There is no stared user</h></div>
|
292
|
-
|
293
|
-
: <ul>{
|
294
|
-
|
295
|
-
this.state.posts.slice().reverse().map(
|
296
|
-
|
297
|
-
function(stared_user){
|
298
|
-
|
299
|
-
return(
|
300
|
-
|
301
|
-
<div className='col s12 m4'>
|
302
|
-
|
303
|
-
<Card>
|
304
|
-
|
305
|
-
<CardTitle title={stared_user.title} subtitle={stared_user.author+ " star:"+stared_user.starCount} />
|
306
|
-
|
307
|
-
<CardText>
|
308
|
-
|
309
|
-
{stared_user.body}
|
310
|
-
|
311
|
-
</CardText>
|
312
|
-
|
313
|
-
</Card>
|
314
|
-
|
315
|
-
</div>
|
316
|
-
|
317
|
-
)
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
)
|
322
|
-
|
323
|
-
}</ul>
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
</div>
|
328
|
-
|
329
|
-
</div>
|
330
|
-
|
331
|
-
</Tab>
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
<Tab label="latest posted users" value="b">
|
336
|
-
|
337
|
-
<div>
|
338
|
-
|
339
|
-
<ul>{
|
340
|
-
|
341
|
-
this.state.posts.slice().reverse().map(
|
342
|
-
|
343
|
-
function(latest_post){
|
344
|
-
|
345
|
-
return(
|
346
|
-
|
347
|
-
<div className='col s12 m4'>
|
348
|
-
|
349
|
-
<Card>
|
350
|
-
|
351
|
-
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
352
|
-
|
353
|
-
<CardText>
|
354
|
-
|
355
|
-
{latest_post.body}
|
356
|
-
|
357
|
-
</CardText>
|
358
|
-
|
359
|
-
</Card>
|
360
|
-
|
361
|
-
</div>
|
362
|
-
|
363
|
-
)
|
364
|
-
|
365
|
-
}
|
366
|
-
|
367
|
-
)
|
368
|
-
|
369
|
-
}</ul>
|
370
|
-
|
371
|
-
</div>
|
372
|
-
|
373
397
|
</Tab>
|
374
398
|
|
375
399
|
</Tabs>
|
@@ -386,6 +410,8 @@
|
|
386
410
|
|
387
411
|
export default Home
|
388
412
|
|
413
|
+
|
414
|
+
|
389
415
|
```
|
390
416
|
|
391
417
|
|
45
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,16 +40,6 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
import React, { Component } from 'react'
|
44
|
-
|
45
|
-
import { Card, CardTitle, CardText } from 'material-ui/Card'
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
import firebase from 'firebase'
|
50
|
-
|
51
|
-
|
52
|
-
|
53
43
|
class Home extends Component {
|
54
44
|
|
55
45
|
constructor(props) {
|
@@ -60,6 +50,12 @@
|
|
60
50
|
|
61
51
|
unsub:'',
|
62
52
|
|
53
|
+
search:'',
|
54
|
+
|
55
|
+
searchReference:'0',
|
56
|
+
|
57
|
+
tabValue:'a',
|
58
|
+
|
63
59
|
off:'',
|
64
60
|
|
65
61
|
userId:'',
|
@@ -82,24 +78,24 @@
|
|
82
78
|
|
83
79
|
if(user){
|
84
80
|
|
81
|
+
self.setState({
|
82
|
+
|
83
|
+
userId : firebase.auth().currentUser.uid
|
84
|
+
|
85
|
+
},self.fetchPosts);
|
86
|
+
|
85
87
|
|
86
88
|
|
87
89
|
}
|
88
90
|
|
89
91
|
else {
|
90
92
|
|
91
|
-
|
93
|
+
self.props.history.push('/login')
|
92
94
|
|
93
95
|
}
|
94
96
|
|
95
97
|
})
|
96
98
|
|
97
|
-
this.setState({
|
98
|
-
|
99
|
-
userId : firebase.auth().currentUser.uid
|
100
|
-
|
101
|
-
});
|
102
|
-
|
103
99
|
this.setState({unsub});
|
104
100
|
|
105
101
|
}
|
@@ -144,6 +140,42 @@
|
|
144
140
|
|
145
141
|
|
146
142
|
|
143
|
+
handleChange_search = (event) => {
|
144
|
+
|
145
|
+
this.setState({
|
146
|
+
|
147
|
+
search: event.target.value,
|
148
|
+
|
149
|
+
});
|
150
|
+
|
151
|
+
};
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
handleSearch = (event) =>{
|
156
|
+
|
157
|
+
const self = this
|
158
|
+
|
159
|
+
firebase.database().ref().startAt(self.state.search).endAt(self.state.search+"\uf8ff").once("value")
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
this.setState({searchReference:'1'});
|
164
|
+
|
165
|
+
};
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
handleChange_Tab = (value) => {
|
170
|
+
|
171
|
+
this.setState({
|
172
|
+
|
173
|
+
tabValue: value,
|
174
|
+
|
175
|
+
});
|
176
|
+
|
177
|
+
};
|
178
|
+
|
147
179
|
|
148
180
|
|
149
181
|
|
@@ -152,6 +184,102 @@
|
|
152
184
|
|
153
185
|
return (
|
154
186
|
|
187
|
+
<div>
|
188
|
+
|
189
|
+
<div className='col s12 m4'>
|
190
|
+
|
191
|
+
<Card>
|
192
|
+
|
193
|
+
<CardText>
|
194
|
+
|
195
|
+
<TextField
|
196
|
+
|
197
|
+
id="search"
|
198
|
+
|
199
|
+
floatingLabelText="type username for search"
|
200
|
+
|
201
|
+
value={this.state.search}
|
202
|
+
|
203
|
+
onChange={this.handleChange_search}
|
204
|
+
|
205
|
+
/>
|
206
|
+
|
207
|
+
<RaisedButton
|
208
|
+
|
209
|
+
label="Search"
|
210
|
+
|
211
|
+
secondary={true}
|
212
|
+
|
213
|
+
onClick={this.handleSearch}
|
214
|
+
|
215
|
+
/>
|
216
|
+
|
217
|
+
</CardText>
|
218
|
+
|
219
|
+
</Card>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
<div>
|
224
|
+
|
225
|
+
{
|
226
|
+
|
227
|
+
this.state.searchReference === 0
|
228
|
+
|
229
|
+
? <div><h>There is no such user</h></div>
|
230
|
+
|
231
|
+
:<ul>{
|
232
|
+
|
233
|
+
this.state.posts.slice().reverse().map(
|
234
|
+
|
235
|
+
function(stared_user){
|
236
|
+
|
237
|
+
return(
|
238
|
+
|
239
|
+
<div className='col s12 m4'>
|
240
|
+
|
241
|
+
<Card>
|
242
|
+
|
243
|
+
<CardTitle title={stared_user.title} subtitle={stared_user.author+ " star:"+stared_user.starCount} />
|
244
|
+
|
245
|
+
<CardText>
|
246
|
+
|
247
|
+
a
|
248
|
+
|
249
|
+
{stared_user.body}
|
250
|
+
|
251
|
+
</CardText>
|
252
|
+
|
253
|
+
</Card>
|
254
|
+
|
255
|
+
</div>
|
256
|
+
|
257
|
+
)
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
)
|
262
|
+
|
263
|
+
}</ul>
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
</div>
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
<Tabs
|
274
|
+
|
275
|
+
value={this.state.tabValue}
|
276
|
+
|
277
|
+
onChange={this.handleChange_Tab}
|
278
|
+
|
279
|
+
>
|
280
|
+
|
281
|
+
<Tab label="Stared users" value="a">
|
282
|
+
|
155
283
|
<div className='container'>
|
156
284
|
|
157
285
|
<div>
|
@@ -200,7 +328,53 @@
|
|
200
328
|
|
201
329
|
</div>
|
202
330
|
|
203
|
-
|
331
|
+
</Tab>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<Tab label="latest posted users" value="b">
|
336
|
+
|
337
|
+
<div>
|
338
|
+
|
339
|
+
<ul>{
|
340
|
+
|
341
|
+
this.state.posts.slice().reverse().map(
|
342
|
+
|
343
|
+
function(latest_post){
|
344
|
+
|
345
|
+
return(
|
346
|
+
|
347
|
+
<div className='col s12 m4'>
|
348
|
+
|
349
|
+
<Card>
|
350
|
+
|
351
|
+
<CardTitle title={latest_post.title} subtitle={latest_post.author+ " star:"+latest_post.starCount} />
|
352
|
+
|
353
|
+
<CardText>
|
354
|
+
|
355
|
+
{latest_post.body}
|
356
|
+
|
357
|
+
</CardText>
|
358
|
+
|
359
|
+
</Card>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
)
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
)
|
368
|
+
|
369
|
+
}</ul>
|
370
|
+
|
371
|
+
</div>
|
372
|
+
|
373
|
+
</Tab>
|
374
|
+
|
375
|
+
</Tabs>
|
376
|
+
|
377
|
+
</div>
|
204
378
|
|
205
379
|
)
|
206
380
|
|
@@ -224,9 +398,9 @@
|
|
224
398
|
|
225
399
|
①スターをつけたユーザーのカードを表示し、そこには最新のユーザーの記事を載せていきます。
|
226
400
|
|
227
|
-
|
401
|
+
❎ユーザーの検索機能。 だいたい目測はついた。
|
228
|
-
|
402
|
+
|
229
|
-
③記事ごとのコメント機能
|
403
|
+
③記事ごとのコメント機能 カードにつける。
|
230
404
|
|
231
405
|
|
232
406
|
|
44
ホームのビュー
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
不明点
|
35
|
+
不明点(ホームのビュー)
|
36
36
|
|
37
37
|
---
|
38
38
|
|
@@ -40,7 +40,17 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
+
import React, { Component } from 'react'
|
44
|
+
|
45
|
+
import { Card, CardTitle, CardText } from 'material-ui/Card'
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
import firebase from 'firebase'
|
50
|
+
|
51
|
+
|
52
|
+
|
43
|
-
class
|
53
|
+
class Home extends Component {
|
44
54
|
|
45
55
|
constructor(props) {
|
46
56
|
|
@@ -50,355 +60,177 @@
|
|
50
60
|
|
51
61
|
unsub:'',
|
52
62
|
|
53
|
-
tabValue:'a',
|
54
|
-
|
55
|
-
|
63
|
+
off:'',
|
56
|
-
|
64
|
+
|
57
|
-
userId:
|
65
|
+
userId:'',
|
58
|
-
|
66
|
+
|
59
|
-
user
|
67
|
+
stared_users: [],
|
60
|
-
|
61
|
-
explain: '',
|
62
|
-
|
63
|
-
post_title:'',
|
64
|
-
|
65
|
-
post_body:'',
|
66
68
|
|
67
69
|
posts: []
|
68
70
|
|
69
71
|
}
|
70
72
|
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
componentWillMount(){
|
78
|
+
|
79
|
+
const self=this
|
80
|
+
|
81
|
+
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
82
|
+
|
83
|
+
if(user){
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
else {
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
})
|
96
|
+
|
97
|
+
this.setState({
|
98
|
+
|
99
|
+
userId : firebase.auth().currentUser.uid
|
100
|
+
|
101
|
+
});
|
102
|
+
|
103
|
+
this.setState({unsub});
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
componentDidMount(){
|
110
|
+
|
111
|
+
const myUserId = this.state.userId
|
112
|
+
|
113
|
+
const self = this
|
114
|
+
|
115
|
+
var onValueChange = firebase.database().ref('/users/'+myUserId+'/stared_users/').on('value',function(snapshot) {
|
116
|
+
|
117
|
+
const stared_users = [];
|
118
|
+
|
119
|
+
snapshot.forEach(function(childSnapshot){
|
120
|
+
|
121
|
+
stared_users.push(childSnapshot.val()),
|
122
|
+
|
123
|
+
self.setState({ stared_users: stared_users });
|
124
|
+
|
125
|
+
})
|
126
|
+
|
127
|
+
});
|
128
|
+
|
129
|
+
this.setState({off:onValueChange})
|
130
|
+
|
71
131
|
}
|
72
132
|
|
133
|
+
|
134
|
+
|
73
|
-
componentWill
|
135
|
+
componentWillUnmount() {
|
74
|
-
|
75
|
-
const self=this
|
76
|
-
|
77
|
-
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
78
|
-
|
79
|
-
if(user){
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
else {
|
86
|
-
|
87
|
-
self.props.history.push('/login')
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
})
|
92
|
-
|
93
|
-
this.setState({
|
94
|
-
|
95
|
-
userId : firebase.auth().currentUser.uid
|
96
|
-
|
97
|
-
});
|
98
|
-
|
99
|
-
this.setState({unsub});
|
100
|
-
|
101
|
-
};
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
componentDidMount(){
|
106
|
-
|
107
|
-
const myUserId = this.state.userId
|
108
136
|
|
109
137
|
const self = this
|
110
138
|
|
111
|
-
firebase.database().ref('/users/'+myUserId).once('value').then(function(snapshot) {
|
112
|
-
|
113
|
-
|
139
|
+
this.state.unsub();
|
114
|
-
|
115
|
-
|
140
|
+
|
116
|
-
|
117
|
-
title: snapshot.val().title,
|
118
|
-
|
119
|
-
explain: snapshot.val().explain
|
120
|
-
|
121
|
-
});
|
122
|
-
|
123
|
-
});
|
124
|
-
|
125
|
-
|
141
|
+
firebase.database().ref('/users/'+this.state.userId+'/stared_users/').off('value', self.state.off)
|
126
|
-
|
127
|
-
|
142
|
+
|
128
|
-
|
129
|
-
snapshot.forEach(function(childSnapshot){
|
130
|
-
|
131
|
-
posts.push(childSnapshot.val()),
|
132
|
-
|
133
|
-
self.setState({ posts: posts });
|
134
|
-
|
135
|
-
})
|
136
|
-
|
137
|
-
|
143
|
+
};
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
render () {
|
152
|
+
|
153
|
+
return (
|
154
|
+
|
155
|
+
<div className='container'>
|
156
|
+
|
157
|
+
<div>
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
this.state.stared_users.length === 0
|
162
|
+
|
163
|
+
? <div><h>There is no stared user</h></div>
|
164
|
+
|
165
|
+
: <ul>{
|
166
|
+
|
167
|
+
this.state.posts.slice().reverse().map(
|
168
|
+
|
169
|
+
function(stared_user){
|
170
|
+
|
171
|
+
return(
|
172
|
+
|
173
|
+
<div className='col s12 m4'>
|
174
|
+
|
175
|
+
<Card>
|
176
|
+
|
177
|
+
<CardTitle title={stared_user.title} subtitle={stared_user.author+ " star:"+stared_user.starCount} />
|
178
|
+
|
179
|
+
<CardText>
|
180
|
+
|
181
|
+
{stared_user.body}
|
182
|
+
|
183
|
+
</CardText>
|
184
|
+
|
185
|
+
</Card>
|
186
|
+
|
187
|
+
</div>
|
188
|
+
|
189
|
+
)
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
)
|
194
|
+
|
195
|
+
}</ul>
|
196
|
+
|
197
|
+
}
|
198
|
+
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</div>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
)
|
206
|
+
|
207
|
+
}
|
138
208
|
|
139
209
|
}
|
140
210
|
|
141
211
|
|
142
212
|
|
143
|
-
|
144
|
-
|
145
|
-
componentWillUnmount() {
|
146
|
-
|
147
|
-
this.state.unsub();
|
148
|
-
|
149
|
-
};
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
handleChange_Tab = (value) => {
|
154
|
-
|
155
|
-
this.setState({
|
156
|
-
|
157
|
-
tabValue: value,
|
158
|
-
|
159
|
-
});
|
160
|
-
|
161
|
-
};
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
handleChange_title = (event) => {
|
166
|
-
|
167
|
-
this.setState({
|
168
|
-
|
169
|
-
post_title: event.target.value
|
170
|
-
|
171
|
-
});
|
172
|
-
|
173
|
-
};
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
handleChange_body = (event) => {
|
178
|
-
|
179
|
-
this.setState({
|
180
|
-
|
181
|
-
post_body: event.target.value
|
182
|
-
|
183
|
-
});
|
184
|
-
|
185
|
-
};
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
handleSubmit=(event) =>{
|
190
|
-
|
191
|
-
const self = this
|
192
|
-
|
193
|
-
function writeNewPost() {
|
194
|
-
|
195
|
-
// A post entry.
|
196
|
-
|
197
|
-
var postData = {
|
198
|
-
|
199
|
-
author: self.state.username,
|
200
|
-
|
201
|
-
uid: self.state.userId,
|
202
|
-
|
203
|
-
body: self.state.post_body,
|
204
|
-
|
205
|
-
title: self.state.post_title,
|
206
|
-
|
207
|
-
starCount: 0,
|
208
|
-
|
209
|
-
};
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
// Get a key for a new Post.
|
214
|
-
|
215
|
-
var newPostKey = firebase.database().ref().child('posts').push().key;
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
// Write the new post's data simultaneously in the posts list and the user's post list.
|
220
|
-
|
221
|
-
var updates = {};
|
222
|
-
|
223
|
-
updates['/posts/' + newPostKey] = postData;
|
224
|
-
|
225
|
-
updates['/users/' + self.state.userId + '/user_posts/' + newPostKey] = postData;
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
return firebase.database().ref().update(updates);
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
writeNewPost()
|
234
|
-
|
235
|
-
this.setState({
|
236
|
-
|
237
|
-
post_title:'',
|
238
|
-
|
239
|
-
post_body:''
|
240
|
-
|
241
|
-
});
|
242
|
-
|
243
|
-
};
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
render() {
|
250
|
-
|
251
|
-
return (
|
252
|
-
|
253
|
-
<div>
|
254
|
-
|
255
|
-
<div className='col s12 m4'>
|
256
|
-
|
257
|
-
<Card>
|
258
|
-
|
259
|
-
<CardTitle title={"MyPage For " + this.state.username}subtitle={this.state.title} />
|
260
|
-
|
261
|
-
<CardText>
|
262
|
-
|
263
|
-
{this.state.explain}
|
264
|
-
|
265
|
-
</CardText>
|
266
|
-
|
267
|
-
</Card>
|
268
|
-
|
269
|
-
</div>
|
270
|
-
|
271
|
-
<Tabs
|
272
|
-
|
273
|
-
value={this.state.tabValue}
|
274
|
-
|
275
|
-
onChange={this.handleChange_Tab}
|
276
|
-
|
277
|
-
>
|
278
|
-
|
279
|
-
<Tab label="POSTING" value="a">
|
280
|
-
|
281
|
-
<div>
|
282
|
-
|
283
|
-
<Card>
|
284
|
-
|
285
|
-
<CardTitle title='Make new post' subtitle={this.state.username} />
|
286
|
-
|
287
|
-
<CardText>
|
288
|
-
|
289
|
-
<TextField
|
290
|
-
|
291
|
-
id="post_title"
|
292
|
-
|
293
|
-
floatingLabelText="type the title"
|
294
|
-
|
295
|
-
value={this.state.post_title}
|
296
|
-
|
297
|
-
onChange={this.handleChange_title}
|
298
|
-
|
299
|
-
/>
|
300
|
-
|
301
|
-
<br />
|
302
|
-
|
303
|
-
<TextField
|
304
|
-
|
305
|
-
floatingLabelText="type the body"
|
306
|
-
|
307
|
-
multiLine={true}
|
308
|
-
|
309
|
-
value={this.state.post_body}
|
310
|
-
|
311
|
-
onChange={this.handleChange_body}
|
312
|
-
|
313
|
-
/>
|
314
|
-
|
315
|
-
<br />
|
316
|
-
|
317
|
-
<RaisedButton
|
318
|
-
|
319
|
-
label="posting"
|
320
|
-
|
321
|
-
secondary={true}
|
322
|
-
|
323
|
-
onClick={this.handleSubmit}
|
324
|
-
|
325
|
-
/>
|
326
|
-
|
327
|
-
<br />
|
328
|
-
|
329
|
-
</CardText>
|
330
|
-
|
331
|
-
</Card>
|
332
|
-
|
333
|
-
</div>
|
334
|
-
|
335
|
-
</Tab>
|
336
|
-
|
337
|
-
<Tab label="POSTED" value="b">
|
338
|
-
|
339
|
-
<div>
|
340
|
-
|
341
|
-
<span>{ this.state.posts.length }</span>
|
342
|
-
|
343
|
-
{
|
344
|
-
|
345
|
-
this.state.posts.length === 0
|
346
|
-
|
347
|
-
? <div><h>There is no post</h></div>
|
348
|
-
|
349
|
-
: <ul>{
|
350
|
-
|
351
|
-
this.state.posts.slice(-5).reverse().map(
|
352
|
-
|
353
|
-
function(post){
|
354
|
-
|
355
|
-
<div className='col s12 m4'>
|
356
|
-
|
357
|
-
<Card>
|
358
|
-
|
359
|
-
<CardTitle title={post.title} subtitle={post.author} />
|
360
|
-
|
361
|
-
<CardText>
|
362
|
-
|
363
|
-
{post.body}
|
364
|
-
|
365
|
-
</CardText>
|
366
|
-
|
367
|
-
</Card>
|
368
|
-
|
369
|
-
</div>
|
370
|
-
|
371
|
-
}
|
372
|
-
|
373
|
-
)
|
374
|
-
|
375
|
-
}</ul>
|
376
|
-
|
377
|
-
}
|
378
|
-
|
379
|
-
</div>
|
380
|
-
|
381
|
-
</Tab>
|
382
|
-
|
383
|
-
</Tabs>
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
</div>
|
388
|
-
|
389
|
-
)}
|
390
|
-
|
391
|
-
}
|
392
|
-
|
393
|
-
export default
|
213
|
+
export default Home
|
394
214
|
|
395
215
|
```
|
396
216
|
|
397
217
|
|
398
218
|
|
399
|
-
|
219
|
+
ホームのビューの簡単なところを作成しました。return内はmypageのコピペも多いので、まだまだ間違いあると思います。
|
220
|
+
|
221
|
+
|
222
|
+
|
400
|
-
|
223
|
+
今後ホームに実装する機能として、
|
224
|
+
|
401
|
-
|
225
|
+
①スターをつけたユーザーのカードを表示し、そこには最新のユーザーの記事を載せていきます。
|
226
|
+
|
227
|
+
②ユーザーの検索機能。 これがないと①の機能を使いづらいのでなんとかしたいです。
|
228
|
+
|
229
|
+
③記事ごとのコメント機能 これはぜひほしい機能ですが、1、2に比べると重要性が薄く、まだまだ先でいいです。
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
などがあります。
|
402
234
|
|
403
235
|
|
404
236
|
|
43
更新。
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,8 +40,6 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
|
44
|
-
|
45
43
|
class MyPage extends Component {
|
46
44
|
|
47
45
|
constructor(props) {
|
@@ -126,10 +124,10 @@
|
|
126
124
|
|
127
125
|
firebase.database().ref('/users/'+myUserId+'/user_posts/').once('value').then(function(snapshot) {
|
128
126
|
|
127
|
+
const posts = [];
|
128
|
+
|
129
129
|
snapshot.forEach(function(childSnapshot){
|
130
130
|
|
131
|
-
const posts = [];
|
132
|
-
|
133
131
|
posts.push(childSnapshot.val()),
|
134
132
|
|
135
133
|
self.setState({ posts: posts });
|
@@ -358,11 +356,11 @@
|
|
358
356
|
|
359
357
|
<Card>
|
360
358
|
|
361
|
-
<CardTitle title={post.
|
359
|
+
<CardTitle title={post.title} subtitle={post.author} />
|
362
360
|
|
363
361
|
<CardText>
|
364
362
|
|
365
|
-
{post.
|
363
|
+
{post.body}
|
366
364
|
|
367
365
|
</CardText>
|
368
366
|
|
@@ -370,7 +368,7 @@
|
|
370
368
|
|
371
369
|
</div>
|
372
370
|
|
373
|
-
|
371
|
+
}
|
374
372
|
|
375
373
|
)
|
376
374
|
|
@@ -394,15 +392,11 @@
|
|
394
392
|
|
395
393
|
export default MyPage
|
396
394
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
395
|
```
|
402
396
|
|
403
397
|
|
404
398
|
|
405
|
-
なんとなく、投稿のビューを作成しました。現在搭載に困っている内容は、POSTEDにて
|
399
|
+
なんとなく、投稿のビューを作成しました。現在搭載に困っている内容は、POSTEDにてカードを表示させたいのですが、表示できません。
|
406
400
|
|
407
401
|
|
408
402
|
|
42
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,6 +40,8 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
+
|
44
|
+
|
43
45
|
class MyPage extends Component {
|
44
46
|
|
45
47
|
constructor(props) {
|
@@ -348,7 +350,7 @@
|
|
348
350
|
|
349
351
|
: <ul>{
|
350
352
|
|
351
|
-
this.state.
|
353
|
+
this.state.posts.slice(-5).reverse().map(
|
352
354
|
|
353
355
|
function(post){
|
354
356
|
|
@@ -356,7 +358,7 @@
|
|
356
358
|
|
357
359
|
<Card>
|
358
360
|
|
359
|
-
<CardTitle title={post.post_title} subtitle={
|
361
|
+
<CardTitle title={post.post_title} subtitle={post.username} />
|
360
362
|
|
361
363
|
<CardText>
|
362
364
|
|
@@ -394,6 +396,8 @@
|
|
394
396
|
|
395
397
|
|
396
398
|
|
399
|
+
|
400
|
+
|
397
401
|
```
|
398
402
|
|
399
403
|
|
41
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -124,13 +124,37 @@
|
|
124
124
|
|
125
125
|
firebase.database().ref('/users/'+myUserId+'/user_posts/').once('value').then(function(snapshot) {
|
126
126
|
|
127
|
+
snapshot.forEach(function(childSnapshot){
|
128
|
+
|
127
|
-
conso
|
129
|
+
const posts = [];
|
128
|
-
|
129
|
-
|
130
|
+
|
130
|
-
|
131
|
-
posts
|
131
|
+
posts.push(childSnapshot.val()),
|
132
|
+
|
132
|
-
|
133
|
+
self.setState({ posts: posts });
|
134
|
+
|
135
|
+
})
|
136
|
+
|
133
|
-
|
137
|
+
});
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
componentWillUnmount() {
|
146
|
+
|
147
|
+
this.state.unsub();
|
148
|
+
|
149
|
+
};
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
handleChange_Tab = (value) => {
|
154
|
+
|
155
|
+
this.setState({
|
156
|
+
|
157
|
+
tabValue: value,
|
134
158
|
|
135
159
|
});
|
136
160
|
|
@@ -138,21 +162,11 @@
|
|
138
162
|
|
139
163
|
|
140
164
|
|
141
|
-
|
142
|
-
|
143
|
-
componentWillUnmount() {
|
144
|
-
|
145
|
-
this.state.unsub();
|
146
|
-
|
147
|
-
};
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
handleChange_
|
165
|
+
handleChange_title = (event) => {
|
152
166
|
|
153
167
|
this.setState({
|
154
168
|
|
155
|
-
t
|
169
|
+
post_title: event.target.value
|
156
170
|
|
157
171
|
});
|
158
172
|
|
@@ -160,11 +174,11 @@
|
|
160
174
|
|
161
175
|
|
162
176
|
|
163
|
-
handleChange_
|
177
|
+
handleChange_body = (event) => {
|
164
178
|
|
165
179
|
this.setState({
|
166
180
|
|
167
|
-
post_
|
181
|
+
post_body: event.target.value
|
168
182
|
|
169
183
|
});
|
170
184
|
|
@@ -172,11 +186,57 @@
|
|
172
186
|
|
173
187
|
|
174
188
|
|
175
|
-
handle
|
189
|
+
handleSubmit=(event) =>{
|
190
|
+
|
191
|
+
const self = this
|
192
|
+
|
193
|
+
function writeNewPost() {
|
194
|
+
|
195
|
+
// A post entry.
|
196
|
+
|
197
|
+
var postData = {
|
198
|
+
|
199
|
+
author: self.state.username,
|
200
|
+
|
201
|
+
uid: self.state.userId,
|
202
|
+
|
203
|
+
body: self.state.post_body,
|
204
|
+
|
205
|
+
title: self.state.post_title,
|
206
|
+
|
207
|
+
starCount: 0,
|
208
|
+
|
209
|
+
};
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
// Get a key for a new Post.
|
214
|
+
|
215
|
+
var newPostKey = firebase.database().ref().child('posts').push().key;
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
// Write the new post's data simultaneously in the posts list and the user's post list.
|
220
|
+
|
221
|
+
var updates = {};
|
222
|
+
|
223
|
+
updates['/posts/' + newPostKey] = postData;
|
224
|
+
|
225
|
+
updates['/users/' + self.state.userId + '/user_posts/' + newPostKey] = postData;
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
return firebase.database().ref().update(updates);
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
writeNewPost()
|
176
234
|
|
177
235
|
this.setState({
|
178
236
|
|
237
|
+
post_title:'',
|
238
|
+
|
179
|
-
post_body:
|
239
|
+
post_body:''
|
180
240
|
|
181
241
|
});
|
182
242
|
|
@@ -184,64 +244,6 @@
|
|
184
244
|
|
185
245
|
|
186
246
|
|
187
|
-
handleSubmit=(event) =>{
|
188
|
-
|
189
|
-
const self = this
|
190
|
-
|
191
|
-
function writeNewPost() {
|
192
|
-
|
193
|
-
// A post entry.
|
194
|
-
|
195
|
-
var postData = {
|
196
|
-
|
197
|
-
author: self.state.username,
|
198
|
-
|
199
|
-
uid: self.state.userId,
|
200
|
-
|
201
|
-
body: self.state.post_body,
|
202
|
-
|
203
|
-
title: self.state.post_title,
|
204
|
-
|
205
|
-
starCount: 0,
|
206
|
-
|
207
|
-
};
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
// Get a key for a new Post.
|
212
|
-
|
213
|
-
var newPostKey = firebase.database().ref().child('posts').push().key;
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
// Write the new post's data simultaneously in the posts list and the user's post list.
|
218
|
-
|
219
|
-
var updates = {};
|
220
|
-
|
221
|
-
updates['/posts/' + newPostKey] = postData;
|
222
|
-
|
223
|
-
updates['/users/' + self.state.userId + '/user_posts/' + newPostKey] = postData;
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
return firebase.database().ref().update(updates);
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
writeNewPost()
|
232
|
-
|
233
|
-
this.setState({
|
234
|
-
|
235
|
-
post_title:'',
|
236
|
-
|
237
|
-
post_body:''
|
238
|
-
|
239
|
-
});
|
240
|
-
|
241
|
-
};
|
242
|
-
|
243
|
-
|
244
|
-
|
245
247
|
|
246
248
|
|
247
249
|
render() {
|
@@ -336,27 +338,41 @@
|
|
336
338
|
|
337
339
|
<div>
|
338
340
|
|
341
|
+
<span>{ this.state.posts.length }</span>
|
342
|
+
|
339
|
-
{
|
343
|
+
{
|
340
|
-
|
344
|
+
|
341
|
-
this.state.posts.length === 0
|
345
|
+
this.state.posts.length === 0
|
342
|
-
|
346
|
+
|
343
|
-
? <div><h>
|
347
|
+
? <div><h>There is no post</h></div>
|
348
|
+
|
344
|
-
|
349
|
+
: <ul>{
|
350
|
+
|
351
|
+
this.state.items.slice(-5).reverse().map(
|
352
|
+
|
353
|
+
function(post){
|
354
|
+
|
345
|
-
|
355
|
+
<div className='col s12 m4'>
|
346
|
-
|
356
|
+
|
347
|
-
<Card>
|
357
|
+
<Card>
|
348
|
-
|
358
|
+
|
349
|
-
<CardTitle title={post
|
359
|
+
<CardTitle title={post.post_title} subtitle={this.state.username} />
|
350
|
-
|
360
|
+
|
351
|
-
<CardText>
|
361
|
+
<CardText>
|
352
|
-
|
362
|
+
|
353
|
-
{post
|
363
|
+
{post.post_body}
|
354
|
-
|
364
|
+
|
355
|
-
</CardText>
|
365
|
+
</CardText>
|
356
|
-
|
366
|
+
|
357
|
-
</Card>
|
367
|
+
</Card>
|
358
|
-
|
368
|
+
|
359
|
-
</div>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
)
|
374
|
+
|
375
|
+
}</ul>
|
360
376
|
|
361
377
|
}
|
362
378
|
|
@@ -376,17 +392,15 @@
|
|
376
392
|
|
377
393
|
export default MyPage
|
378
394
|
|
395
|
+
|
396
|
+
|
379
397
|
```
|
380
398
|
|
381
399
|
|
382
400
|
|
383
|
-
なんとなく、投稿のビューを作成しました。現在搭載に困っている内容は、
|
401
|
+
なんとなく、投稿のビューを作成しました。現在搭載に困っている内容は、POSTEDにて投稿があるときは最近の投稿5つを降順(最新の投稿順)で表示させたいです。、降順による表示を施工中です。がいまいちわかりません。
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
402
|
+
|
388
|
-
|
389
|
-
|
403
|
+
|
390
404
|
|
391
405
|
|
392
406
|
|
40
カードの中身を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -346,11 +346,11 @@
|
|
346
346
|
|
347
347
|
<Card>
|
348
348
|
|
349
|
-
<CardTitle title={t
|
349
|
+
<CardTitle title={posts.post_title} subtitle={this.state.username} />
|
350
350
|
|
351
351
|
<CardText>
|
352
352
|
|
353
|
-
{t
|
353
|
+
{posts.post_body}
|
354
354
|
|
355
355
|
</CardText>
|
356
356
|
|
39
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,9 +62,9 @@
|
|
62
62
|
|
63
63
|
post_title:'',
|
64
64
|
|
65
|
-
post_
|
65
|
+
post_body:'',
|
66
|
-
|
66
|
+
|
67
|
-
|
67
|
+
posts: []
|
68
68
|
|
69
69
|
}
|
70
70
|
|
@@ -120,8 +120,20 @@
|
|
120
120
|
|
121
121
|
});
|
122
122
|
|
123
|
+
});
|
124
|
+
|
125
|
+
firebase.database().ref('/users/'+myUserId+'/user_posts/').once('value').then(function(snapshot) {
|
126
|
+
|
127
|
+
console.log(snapshot.val())
|
128
|
+
|
129
|
+
self.setState({
|
130
|
+
|
131
|
+
posts: snapshot.val(),
|
132
|
+
|
123
133
|
});
|
124
134
|
|
135
|
+
});
|
136
|
+
|
125
137
|
};
|
126
138
|
|
127
139
|
|
@@ -160,11 +172,11 @@
|
|
160
172
|
|
161
173
|
|
162
174
|
|
163
|
-
handleChange_
|
175
|
+
handleChange_body = (event) => {
|
164
|
-
|
176
|
+
|
165
|
-
this.setState({
|
177
|
+
this.setState({
|
166
|
-
|
178
|
+
|
167
|
-
post_
|
179
|
+
post_body: event.target.value
|
168
180
|
|
169
181
|
});
|
170
182
|
|
@@ -174,17 +186,61 @@
|
|
174
186
|
|
175
187
|
handleSubmit=(event) =>{
|
176
188
|
|
189
|
+
const self = this
|
190
|
+
|
177
|
-
|
191
|
+
function writeNewPost() {
|
192
|
+
|
178
|
-
|
193
|
+
// A post entry.
|
194
|
+
|
195
|
+
var postData = {
|
196
|
+
|
179
|
-
|
197
|
+
author: self.state.username,
|
198
|
+
|
180
|
-
|
199
|
+
uid: self.state.userId,
|
200
|
+
|
201
|
+
body: self.state.post_body,
|
202
|
+
|
181
|
-
|
203
|
+
title: self.state.post_title,
|
182
|
-
|
204
|
+
|
183
|
-
|
205
|
+
starCount: 0,
|
184
|
-
|
185
|
-
|
206
|
+
|
186
|
-
|
187
|
-
};
|
207
|
+
};
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
// Get a key for a new Post.
|
212
|
+
|
213
|
+
var newPostKey = firebase.database().ref().child('posts').push().key;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
// Write the new post's data simultaneously in the posts list and the user's post list.
|
218
|
+
|
219
|
+
var updates = {};
|
220
|
+
|
221
|
+
updates['/posts/' + newPostKey] = postData;
|
222
|
+
|
223
|
+
updates['/users/' + self.state.userId + '/user_posts/' + newPostKey] = postData;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
return firebase.database().ref().update(updates);
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
writeNewPost()
|
232
|
+
|
233
|
+
this.setState({
|
234
|
+
|
235
|
+
post_title:'',
|
236
|
+
|
237
|
+
post_body:''
|
238
|
+
|
239
|
+
});
|
240
|
+
|
241
|
+
};
|
242
|
+
|
243
|
+
|
188
244
|
|
189
245
|
|
190
246
|
|
@@ -236,7 +292,7 @@
|
|
236
292
|
|
237
293
|
value={this.state.post_title}
|
238
294
|
|
239
|
-
onChange={this.handleChange_tite}
|
295
|
+
onChange={this.handleChange_title}
|
240
296
|
|
241
297
|
/>
|
242
298
|
|
@@ -244,13 +300,13 @@
|
|
244
300
|
|
245
301
|
<TextField
|
246
302
|
|
247
|
-
floatingLabelText="p
|
303
|
+
floatingLabelText="type the body"
|
248
304
|
|
249
305
|
multiLine={true}
|
250
306
|
|
251
|
-
value={this.state.post_
|
307
|
+
value={this.state.post_body}
|
252
|
-
|
308
|
+
|
253
|
-
onChange={this.handleChange_
|
309
|
+
onChange={this.handleChange_body}
|
254
310
|
|
255
311
|
/>
|
256
312
|
|
@@ -280,31 +336,39 @@
|
|
280
336
|
|
281
337
|
<div>
|
282
338
|
|
339
|
+
{
|
340
|
+
|
341
|
+
this.state.posts.length === 0
|
342
|
+
|
343
|
+
? <div><h>No entries</h></div>
|
344
|
+
|
283
|
-
<div className='col s12 m4'>
|
345
|
+
: <div className='col s12 m4'>
|
284
|
-
|
346
|
+
|
285
|
-
<Card>
|
347
|
+
<Card>
|
286
|
-
|
348
|
+
|
287
|
-
<CardTitle title={this.state.post_title} subtitle={this.state.username} />
|
349
|
+
<CardTitle title={this.state.post_title} subtitle={this.state.username} />
|
288
|
-
|
350
|
+
|
289
|
-
<CardText>
|
351
|
+
<CardText>
|
290
|
-
|
352
|
+
|
291
|
-
{this.state.post_
|
353
|
+
{this.state.post_body}
|
292
|
-
|
354
|
+
|
293
|
-
</CardText>
|
355
|
+
</CardText>
|
294
|
-
|
356
|
+
|
295
|
-
</Card>
|
357
|
+
</Card>
|
296
|
-
|
358
|
+
|
297
|
-
</div>
|
359
|
+
</div>
|
360
|
+
|
298
|
-
|
361
|
+
}
|
362
|
+
|
299
|
-
</div>
|
363
|
+
</div>
|
300
|
-
|
364
|
+
|
301
|
-
</Tab>
|
365
|
+
</Tab>
|
302
|
-
|
366
|
+
|
303
|
-
</Tabs>
|
367
|
+
</Tabs>
|
304
|
-
|
305
|
-
|
306
|
-
|
368
|
+
|
369
|
+
|
370
|
+
|
307
|
-
</div>
|
371
|
+
</div>
|
308
372
|
|
309
373
|
)}
|
310
374
|
|
@@ -312,8 +376,6 @@
|
|
312
376
|
|
313
377
|
export default MyPage
|
314
378
|
|
315
|
-
|
316
|
-
|
317
379
|
```
|
318
380
|
|
319
381
|
|
38
投稿のビューの不明点。
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,6 +50,8 @@
|
|
50
50
|
|
51
51
|
unsub:'',
|
52
52
|
|
53
|
+
tabValue:'a',
|
54
|
+
|
53
55
|
title: '',
|
54
56
|
|
55
57
|
userId: '',
|
@@ -58,6 +60,10 @@
|
|
58
60
|
|
59
61
|
explain: '',
|
60
62
|
|
63
|
+
post_title:'',
|
64
|
+
|
65
|
+
post_explain:'',
|
66
|
+
|
61
67
|
items: []
|
62
68
|
|
63
69
|
}
|
@@ -130,6 +136,58 @@
|
|
130
136
|
|
131
137
|
|
132
138
|
|
139
|
+
handleChange_Tab = (value) => {
|
140
|
+
|
141
|
+
this.setState({
|
142
|
+
|
143
|
+
tabValue: value,
|
144
|
+
|
145
|
+
});
|
146
|
+
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
handleChange_title = (event) => {
|
152
|
+
|
153
|
+
this.setState({
|
154
|
+
|
155
|
+
post_title: event.target.value
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
};
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
handleChange_explain = (event) => {
|
164
|
+
|
165
|
+
this.setState({
|
166
|
+
|
167
|
+
post_explain: event.target.value
|
168
|
+
|
169
|
+
});
|
170
|
+
|
171
|
+
};
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
handleSubmit=(event) =>{
|
176
|
+
|
177
|
+
event.preventDefault();
|
178
|
+
|
179
|
+
firebase.database().ref('users/' + this.state.userId+'/posts/').set({
|
180
|
+
|
181
|
+
post_title: this.state.post_title,
|
182
|
+
|
183
|
+
post_explain: this.state.post_explain
|
184
|
+
|
185
|
+
})
|
186
|
+
|
187
|
+
};
|
188
|
+
|
189
|
+
|
190
|
+
|
133
191
|
render() {
|
134
192
|
|
135
193
|
return (
|
@@ -140,7 +198,7 @@
|
|
140
198
|
|
141
199
|
<Card>
|
142
200
|
|
143
|
-
<CardTitle title=
|
201
|
+
<CardTitle title={"MyPage For " + this.state.username}subtitle={this.state.title} />
|
144
202
|
|
145
203
|
<CardText>
|
146
204
|
|
@@ -152,6 +210,100 @@
|
|
152
210
|
|
153
211
|
</div>
|
154
212
|
|
213
|
+
<Tabs
|
214
|
+
|
215
|
+
value={this.state.tabValue}
|
216
|
+
|
217
|
+
onChange={this.handleChange_Tab}
|
218
|
+
|
219
|
+
>
|
220
|
+
|
221
|
+
<Tab label="POSTING" value="a">
|
222
|
+
|
223
|
+
<div>
|
224
|
+
|
225
|
+
<Card>
|
226
|
+
|
227
|
+
<CardTitle title='Make new post' subtitle={this.state.username} />
|
228
|
+
|
229
|
+
<CardText>
|
230
|
+
|
231
|
+
<TextField
|
232
|
+
|
233
|
+
id="post_title"
|
234
|
+
|
235
|
+
floatingLabelText="type the title"
|
236
|
+
|
237
|
+
value={this.state.post_title}
|
238
|
+
|
239
|
+
onChange={this.handleChange_tite}
|
240
|
+
|
241
|
+
/>
|
242
|
+
|
243
|
+
<br />
|
244
|
+
|
245
|
+
<TextField
|
246
|
+
|
247
|
+
floatingLabelText="post_explaination"
|
248
|
+
|
249
|
+
multiLine={true}
|
250
|
+
|
251
|
+
value={this.state.post_explain}
|
252
|
+
|
253
|
+
onChange={this.handleChange_explain}
|
254
|
+
|
255
|
+
/>
|
256
|
+
|
257
|
+
<br />
|
258
|
+
|
259
|
+
<RaisedButton
|
260
|
+
|
261
|
+
label="posting"
|
262
|
+
|
263
|
+
secondary={true}
|
264
|
+
|
265
|
+
onClick={this.handleSubmit}
|
266
|
+
|
267
|
+
/>
|
268
|
+
|
269
|
+
<br />
|
270
|
+
|
271
|
+
</CardText>
|
272
|
+
|
273
|
+
</Card>
|
274
|
+
|
275
|
+
</div>
|
276
|
+
|
277
|
+
</Tab>
|
278
|
+
|
279
|
+
<Tab label="POSTED" value="b">
|
280
|
+
|
281
|
+
<div>
|
282
|
+
|
283
|
+
<div className='col s12 m4'>
|
284
|
+
|
285
|
+
<Card>
|
286
|
+
|
287
|
+
<CardTitle title={this.state.post_title} subtitle={this.state.username} />
|
288
|
+
|
289
|
+
<CardText>
|
290
|
+
|
291
|
+
{this.state.post_explain}
|
292
|
+
|
293
|
+
</CardText>
|
294
|
+
|
295
|
+
</Card>
|
296
|
+
|
297
|
+
</div>
|
298
|
+
|
299
|
+
</div>
|
300
|
+
|
301
|
+
</Tab>
|
302
|
+
|
303
|
+
</Tabs>
|
304
|
+
|
305
|
+
|
306
|
+
|
155
307
|
</div>
|
156
308
|
|
157
309
|
)}
|
@@ -160,11 +312,19 @@
|
|
160
312
|
|
161
313
|
export default MyPage
|
162
314
|
|
315
|
+
|
316
|
+
|
163
317
|
```
|
164
318
|
|
319
|
+
|
320
|
+
|
321
|
+
なんとなく、投稿のビューを作成しました。現在搭載に困っている内容は、投稿がないときはPOSTEDにてyour posting does not exsist.と表示。投稿があるときは最近の投稿5つを降順(最新の投稿順)で表示させたいです。この場合分けと、降順による表示の考え方がいまいちわかりません。
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
また、投稿ごとにファイアーベースのデータベースを管理する方法もいまいちわかっていませんが、こちらは頑張って試行錯誤します。
|
326
|
+
|
165
|
-
|
327
|
+
前述の内容の手助けお願いします。
|
166
|
-
|
167
|
-
こうすると{username}だったり、 {this.state.explain}が出てこなかったり。syntaxの問題だとは思いますが、基礎が抜けててわかりません申し訳ないです。教えてもらえると助かります。
|
168
328
|
|
169
329
|
|
170
330
|
|
37
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,6 +52,8 @@
|
|
52
52
|
|
53
53
|
title: '',
|
54
54
|
|
55
|
+
userId: '',
|
56
|
+
|
55
57
|
username: '',
|
56
58
|
|
57
59
|
explain: '',
|
@@ -82,6 +84,12 @@
|
|
82
84
|
|
83
85
|
})
|
84
86
|
|
87
|
+
this.setState({
|
88
|
+
|
89
|
+
userId : firebase.auth().currentUser.uid
|
90
|
+
|
91
|
+
});
|
92
|
+
|
85
93
|
this.setState({unsub});
|
86
94
|
|
87
95
|
};
|
@@ -90,11 +98,21 @@
|
|
90
98
|
|
91
99
|
componentDidMount(){
|
92
100
|
|
93
|
-
const myUserId =
|
101
|
+
const myUserId = this.state.userId
|
102
|
+
|
103
|
+
const self = this
|
94
104
|
|
95
105
|
firebase.database().ref('/users/'+myUserId).once('value').then(function(snapshot) {
|
96
106
|
|
107
|
+
self.setState({
|
108
|
+
|
97
|
-
|
109
|
+
username: snapshot.val().user,
|
110
|
+
|
111
|
+
title: snapshot.val().title,
|
112
|
+
|
113
|
+
explain: snapshot.val().explain
|
114
|
+
|
115
|
+
});
|
98
116
|
|
99
117
|
});
|
100
118
|
|
@@ -122,7 +140,7 @@
|
|
122
140
|
|
123
141
|
<Card>
|
124
142
|
|
125
|
-
<CardTitle title='Mypage for {this.state.username}' subtitle=
|
143
|
+
<CardTitle title='Mypage for {this.state.username}' subtitle={this.state.title} />
|
126
144
|
|
127
145
|
<CardText>
|
128
146
|
|
@@ -142,8 +160,6 @@
|
|
142
160
|
|
143
161
|
export default MyPage
|
144
162
|
|
145
|
-
|
146
|
-
|
147
163
|
```
|
148
164
|
|
149
165
|
表示のさせ方にトラブルです。
|
36
コード更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,8 +52,6 @@
|
|
52
52
|
|
53
53
|
title: '',
|
54
54
|
|
55
|
-
userId:'',
|
56
|
-
|
57
55
|
username: '',
|
58
56
|
|
59
57
|
explain: '',
|
@@ -72,11 +70,7 @@
|
|
72
70
|
|
73
71
|
if(user){
|
74
72
|
|
75
|
-
self.setState({
|
76
73
|
|
77
|
-
userId : firebase.auth().currentUser.uid
|
78
|
-
|
79
|
-
})
|
80
74
|
|
81
75
|
}
|
82
76
|
|
@@ -96,7 +90,7 @@
|
|
96
90
|
|
97
91
|
componentDidMount(){
|
98
92
|
|
99
|
-
const myUserId =
|
93
|
+
const myUserId = firebase.auth().currentUser.uid
|
100
94
|
|
101
95
|
firebase.database().ref('/users/'+myUserId).once('value').then(function(snapshot) {
|
102
96
|
|
@@ -148,6 +142,8 @@
|
|
148
142
|
|
149
143
|
export default MyPage
|
150
144
|
|
145
|
+
|
146
|
+
|
151
147
|
```
|
152
148
|
|
153
149
|
表示のさせ方にトラブルです。
|
35
コード更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
JSのみで投稿サイトのビュー
|
test
CHANGED
File without changes
|
34
コード更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
JSのみで投稿サイトのビュー
|
1
|
+
あJSのみで投稿サイトのビュー
|
test
CHANGED
@@ -50,9 +50,9 @@
|
|
50
50
|
|
51
51
|
unsub:'',
|
52
52
|
|
53
|
+
title: '',
|
54
|
+
|
53
55
|
userId:'',
|
54
|
-
|
55
|
-
title: '',
|
56
56
|
|
57
57
|
username: '',
|
58
58
|
|
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
userId : firebase.auth().currentUser.uid
|
78
78
|
|
79
|
-
})
|
79
|
+
})
|
80
80
|
|
81
81
|
}
|
82
82
|
|
@@ -96,23 +96,17 @@
|
|
96
96
|
|
97
97
|
componentDidMount(){
|
98
98
|
|
99
|
-
const se
|
99
|
+
const myUserId = this.state.userId
|
100
100
|
|
101
|
-
firebase.database().ref().once('value').then(function(snapshot) {
|
101
|
+
firebase.database().ref('/users/'+myUserId).once('value').then(function(snapshot) {
|
102
102
|
|
103
|
-
self.setState({
|
104
|
-
|
105
|
-
username:snapshot.val().user,
|
106
|
-
|
107
|
-
explain:snapshot.val().explain,
|
108
|
-
|
109
|
-
|
103
|
+
console.log(snapshot.val())
|
110
|
-
|
111
|
-
})
|
112
104
|
|
113
105
|
});
|
114
106
|
|
115
107
|
};
|
108
|
+
|
109
|
+
|
116
110
|
|
117
111
|
|
118
112
|
|
@@ -134,7 +128,7 @@
|
|
134
128
|
|
135
129
|
<Card>
|
136
130
|
|
137
|
-
<CardTitle title='Mypage for {username}' subtitle='{this.state.title}'/>
|
131
|
+
<CardTitle title='Mypage for {this.state.username}' subtitle='{this.state.title}'/>
|
138
132
|
|
139
133
|
<CardText>
|
140
134
|
|
@@ -152,6 +146,8 @@
|
|
152
146
|
|
153
147
|
}
|
154
148
|
|
149
|
+
export default MyPage
|
150
|
+
|
155
151
|
```
|
156
152
|
|
157
153
|
表示のさせ方にトラブルです。
|
33
JS表示のstntaxがわからない。
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,9 +48,11 @@
|
|
48
48
|
|
49
49
|
this.state = {
|
50
50
|
|
51
|
+
unsub:'',
|
52
|
+
|
51
53
|
userId:'',
|
52
54
|
|
53
|
-
|
55
|
+
title: '',
|
54
56
|
|
55
57
|
username: '',
|
56
58
|
|
@@ -66,9 +68,15 @@
|
|
66
68
|
|
67
69
|
const self=this
|
68
70
|
|
69
|
-
firebase.auth().onAuthStateChanged(function(user){
|
71
|
+
var unsub = firebase.auth().onAuthStateChanged(function(user){
|
70
72
|
|
71
73
|
if(user){
|
74
|
+
|
75
|
+
self.setState({
|
76
|
+
|
77
|
+
userId : firebase.auth().currentUser.uid
|
78
|
+
|
79
|
+
});
|
72
80
|
|
73
81
|
}
|
74
82
|
|
@@ -80,11 +88,7 @@
|
|
80
88
|
|
81
89
|
})
|
82
90
|
|
83
|
-
this.setState({
|
91
|
+
this.setState({unsub});
|
84
|
-
|
85
|
-
userId : firebase.auth().currentUser.uid
|
86
|
-
|
87
|
-
});
|
88
92
|
|
89
93
|
};
|
90
94
|
|
@@ -92,21 +96,31 @@
|
|
92
96
|
|
93
97
|
componentDidMount(){
|
94
98
|
|
95
|
-
const
|
99
|
+
const self = this
|
96
100
|
|
97
|
-
const
|
101
|
+
firebase.database().ref().once('value').then(function(snapshot) {
|
98
102
|
|
99
|
-
|
103
|
+
self.setState({
|
100
104
|
|
101
|
-
user:
|
105
|
+
username:snapshot.val().user,
|
102
106
|
|
103
|
-
explain:
|
107
|
+
explain:snapshot.val().explain,
|
104
108
|
|
109
|
+
title:snapshot.val().title
|
110
|
+
|
105
|
-
}
|
111
|
+
})
|
112
|
+
|
113
|
+
});
|
106
114
|
|
107
115
|
};
|
108
116
|
|
109
117
|
|
118
|
+
|
119
|
+
componentWillUnmount() {
|
120
|
+
|
121
|
+
this.state.unsub();
|
122
|
+
|
123
|
+
};
|
110
124
|
|
111
125
|
|
112
126
|
|
@@ -138,11 +152,11 @@
|
|
138
152
|
|
139
153
|
}
|
140
154
|
|
141
|
-
export default MyPage
|
142
|
-
|
143
155
|
```
|
144
156
|
|
157
|
+
表示のさせ方にトラブルです。
|
158
|
+
|
145
|
-
|
159
|
+
こうすると{username}だったり、 {this.state.explain}が出てこなかったり。syntaxの問題だとは思いますが、基礎が抜けててわかりません申し訳ないです。教えてもらえると助かります。
|
146
160
|
|
147
161
|
|
148
162
|
|
32
makemypageじゃなくてmakemypageでした
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
```js
|
42
42
|
|
43
|
-
class
|
43
|
+
class MyPage extends Component {
|
44
44
|
|
45
45
|
constructor(props) {
|
46
46
|
|
@@ -138,7 +138,7 @@
|
|
138
138
|
|
139
139
|
}
|
140
140
|
|
141
|
-
export default
|
141
|
+
export default MyPage
|
142
142
|
|
143
143
|
```
|
144
144
|
|
31
困っていること
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,11 +38,111 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
```js
|
42
|
+
|
43
|
+
class makeMyPage extends Component {
|
44
|
+
|
45
|
+
constructor(props) {
|
46
|
+
|
47
|
+
super(props);
|
48
|
+
|
49
|
+
this.state = {
|
50
|
+
|
51
|
+
userId:'',
|
52
|
+
|
53
|
+
currentItem: '',
|
54
|
+
|
55
|
+
username: '',
|
56
|
+
|
57
|
+
explain: '',
|
58
|
+
|
59
|
+
items: []
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
componentWillMount(){
|
66
|
+
|
67
|
+
const self=this
|
68
|
+
|
41
|
-
|
69
|
+
firebase.auth().onAuthStateChanged(function(user){
|
70
|
+
|
71
|
+
if(user){
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
else {
|
76
|
+
|
77
|
+
self.props.history.push('/login')
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
})
|
82
|
+
|
83
|
+
this.setState({
|
84
|
+
|
85
|
+
userId : firebase.auth().currentUser.uid
|
86
|
+
|
87
|
+
});
|
88
|
+
|
89
|
+
};
|
42
90
|
|
43
91
|
|
44
92
|
|
93
|
+
componentDidMount(){
|
94
|
+
|
95
|
+
const itemsRef = firebase.database().ref(this.state.userId);
|
96
|
+
|
97
|
+
const item = {
|
98
|
+
|
99
|
+
title: this.state.currentItem,
|
100
|
+
|
101
|
+
user: this.state.username,
|
102
|
+
|
103
|
+
explain: this.state.explain
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
};
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
render() {
|
114
|
+
|
115
|
+
return (
|
116
|
+
|
117
|
+
<div>
|
118
|
+
|
119
|
+
<div className='col s12 m4'>
|
120
|
+
|
121
|
+
<Card>
|
122
|
+
|
123
|
+
<CardTitle title='Mypage for {username}' subtitle='{this.state.title}'/>
|
124
|
+
|
125
|
+
<CardText>
|
126
|
+
|
127
|
+
{this.state.explain}
|
128
|
+
|
129
|
+
</CardText>
|
130
|
+
|
131
|
+
</Card>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
)}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
export default makeMyPage
|
142
|
+
|
143
|
+
```
|
144
|
+
|
45
|
-
|
145
|
+
データーベースからデータを取ってくるところまではできたと思うのですが、これを取得して、renderで表示する方法に困っています。
|
46
146
|
|
47
147
|
|
48
148
|
|
30
新規
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
JSのみで
|
1
|
+
JSのみで投稿サイトのビュー
|
test
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
- 搭載したい機能リスト
|
6
6
|
|
7
|
-
|
7
|
+
・ユーザー認証(とりあえずは完成。)
|
8
8
|
|
9
9
|
ーー(ページごとにユーザーのみ、ゲストのみと分けたい。)
|
10
10
|
|
11
|
-
|
11
|
+
進行中→●ゲスト、ユーザーが見れるプラットホーム。
|
12
12
|
|
13
13
|
ーー(ユーザーが投稿した内容が時系列で表示)
|
14
14
|
|
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
|
27
|
+
ユーザー認証はFirebase経由で行っています。
|
28
28
|
|
29
29
|
reduxは使いたくない!再三のバグ襲来に疲れました。
|
30
30
|
|
@@ -38,121 +38,11 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
```components/SideNav.js
|
42
|
-
|
43
|
-
|
41
|
+
現在。投稿型ホームのビューを作ろうとしています。userの入力を受け取って、それを記事としてホームに追加するといった機能を導入したいです。
|
44
|
-
|
45
|
-
constructor (props) {
|
46
|
-
|
47
|
-
super(props)
|
48
|
-
|
49
|
-
this.state = {
|
50
|
-
|
51
|
-
open: false,
|
52
|
-
|
53
|
-
user: null
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
}
|
58
42
|
|
59
43
|
|
60
44
|
|
61
|
-
componentWillMount() {
|
62
|
-
|
63
|
-
var userstate= firebase.auth().currentUser;
|
64
|
-
|
65
|
-
this.setState({
|
66
|
-
|
67
|
-
user: userstate
|
68
|
-
|
69
|
-
});
|
70
|
-
|
71
|
-
};
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
handleClose = () => this.setState({ open: false })
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
render () {
|
80
|
-
|
81
|
-
return (
|
82
|
-
|
83
|
-
<div>
|
84
|
-
|
85
|
-
<AppBar
|
86
|
-
|
87
|
-
title='plz donation'
|
88
|
-
|
89
|
-
iconElementRight={
|
90
|
-
|
91
|
-
(this.state.user==null) ? <SideLoginButton></SideLoginButton>: <LogoutBtn></LogoutBtn>
|
92
|
-
|
93
|
-
}
|
94
|
-
|
95
|
-
onLeftIconButtonTouchTap={() =>
|
96
|
-
|
97
|
-
this.setState({ open: !this.state.open })}
|
98
|
-
|
99
|
-
/>
|
100
|
-
|
101
|
-
<Drawer
|
102
|
-
|
103
|
-
open={this.state.open}
|
104
|
-
|
105
|
-
docked={false}
|
106
|
-
|
107
|
-
onRequestChange={open => this.setState({ open })}
|
108
|
-
|
109
|
-
>
|
110
|
-
|
111
|
-
<List>
|
112
|
-
|
113
|
-
{links.map((link, i) => {
|
114
|
-
|
115
|
-
return (
|
116
|
-
|
117
|
-
<SideBarItem
|
118
|
-
|
119
|
-
isExact={link.isExact}
|
120
|
-
|
121
|
-
linkTo={link.linkTo}
|
122
|
-
|
123
|
-
primaryText={link.text}
|
124
|
-
|
125
|
-
onClick={this.handleClose}
|
126
|
-
|
127
|
-
key={i}
|
128
|
-
|
129
|
-
/>
|
130
|
-
|
131
|
-
)
|
132
|
-
|
133
|
-
})}
|
134
|
-
|
135
|
-
</List>
|
136
|
-
|
137
|
-
</Drawer>
|
138
|
-
|
139
|
-
</div>
|
140
|
-
|
141
|
-
)
|
142
|
-
|
143
|
-
}
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
```
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
45
|
+
まずは簡単にタイトルを記入して追加させるという機能を使って、投稿のビューがどうなってるかを学びたいです。
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
二項演算子で何か間違っている点あるのでしょうか?それとも、このコンポーネントをリロードしないといけないのでしょうか?
|
156
46
|
|
157
47
|
|
158
48
|
|
29
新たなエラー
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,7 +48,9 @@
|
|
48
48
|
|
49
49
|
this.state = {
|
50
50
|
|
51
|
-
open: false
|
51
|
+
open: false,
|
52
|
+
|
53
|
+
user: null
|
52
54
|
|
53
55
|
}
|
54
56
|
|
@@ -58,15 +60,13 @@
|
|
58
60
|
|
59
61
|
componentWillMount() {
|
60
62
|
|
61
|
-
var c
|
63
|
+
var userstate= firebase.auth().currentUser;
|
62
64
|
|
63
|
-
|
65
|
+
this.setState({
|
64
66
|
|
65
|
-
|
67
|
+
user: userstate
|
66
68
|
|
67
|
-
firebase.initializeApp(config)
|
68
|
-
|
69
|
-
|
69
|
+
});
|
70
70
|
|
71
71
|
};
|
72
72
|
|
@@ -88,7 +88,7 @@
|
|
88
88
|
|
89
89
|
iconElementRight={
|
90
90
|
|
91
|
-
user ? <SideLoginButton
|
91
|
+
(this.state.user==null) ? <SideLoginButton></SideLoginButton>: <LogoutBtn></LogoutBtn>
|
92
92
|
|
93
93
|
}
|
94
94
|
|
@@ -148,7 +148,11 @@
|
|
148
148
|
|
149
149
|
|
150
150
|
|
151
|
-
|
151
|
+
コンパイルはできるようになりました。しかし、ログイン状態、ログアウト状態に関わらず、ボタンがずっとログインボタンのままです。
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
二項演算子で何か間違っている点あるのでしょうか?それとも、このコンポーネントをリロードしないといけないのでしょうか?
|
152
156
|
|
153
157
|
|
154
158
|
|
28
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,6 +25,8 @@
|
|
25
25
|
|
26
26
|
|
27
27
|
現在、ユーザー認証はFirebase経由で行います。
|
28
|
+
|
29
|
+
reduxは使いたくない!再三のバグ襲来に疲れました。
|
28
30
|
|
29
31
|
|
30
32
|
|
27
不明点
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,9 +44,29 @@
|
|
44
44
|
|
45
45
|
super(props)
|
46
46
|
|
47
|
-
this.state = {
|
47
|
+
this.state = {
|
48
|
+
|
49
|
+
open: false
|
50
|
+
|
51
|
+
}
|
48
52
|
|
49
53
|
}
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
componentWillMount() {
|
58
|
+
|
59
|
+
var config = {
|
60
|
+
|
61
|
+
//hide
|
62
|
+
|
63
|
+
};
|
64
|
+
|
65
|
+
firebase.initializeApp(config)
|
66
|
+
|
67
|
+
var user = firebase.auth().currentUser;
|
68
|
+
|
69
|
+
};
|
50
70
|
|
51
71
|
|
52
72
|
|
@@ -64,7 +84,11 @@
|
|
64
84
|
|
65
85
|
title='plz donation'
|
66
86
|
|
87
|
+
iconElementRight={
|
88
|
+
|
67
|
-
|
89
|
+
user ? <SideLoginButton />:<LogoutBtn />
|
90
|
+
|
91
|
+
}
|
68
92
|
|
69
93
|
onLeftIconButtonTouchTap={() =>
|
70
94
|
|
@@ -118,29 +142,11 @@
|
|
118
142
|
|
119
143
|
}
|
120
144
|
|
121
|
-
|
122
|
-
|
123
145
|
```
|
124
|
-
|
125
|
-
この、ログインボタンの部分を、ログイン中はログアウトボタンに変えたいです。ログイン中かどうかはrender外のfirebase.auth().onAuthStateChanged(function(user){
|
126
|
-
|
127
|
-
if(user){
|
128
146
|
|
129
147
|
|
130
148
|
|
131
|
-
}
|
132
|
-
|
133
|
-
else {
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}
|
138
|
-
|
139
|
-
})
|
140
|
-
|
141
|
-
こいつで判別できるとして。
|
142
|
-
|
143
|
-
re
|
149
|
+
自分のイメージでは var user = firebase.auth().currentUser をcomponentWillMountで、コンポーネント作成前にuserを定義し、renderのAppbarのuserで条件分岐させようと思ったのですが、render内のuserがnot definedです。
|
144
150
|
|
145
151
|
|
146
152
|
|
26
ログアウトボタンについて
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,149 +36,79 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
```js
|
39
|
+
```components/SideNav.js
|
40
40
|
|
41
|
-
class
|
41
|
+
class SideNav extends Component {
|
42
42
|
|
43
|
-
|
43
|
+
constructor (props) {
|
44
44
|
|
45
45
|
super(props)
|
46
46
|
|
47
|
-
this.state = {
|
47
|
+
this.state = { open: false }
|
48
|
-
|
49
|
-
email: '',
|
50
|
-
|
51
|
-
password:''
|
52
|
-
|
53
|
-
};
|
54
48
|
|
55
49
|
}
|
56
50
|
|
57
51
|
|
58
52
|
|
59
|
-
componentWillMount() {
|
60
|
-
|
61
|
-
var config = {
|
62
|
-
|
63
|
-
|
53
|
+
handleClose = () => this.setState({ open: false })
|
64
|
-
|
65
|
-
};
|
66
54
|
|
67
55
|
|
68
56
|
|
69
|
-
|
57
|
+
render () {
|
70
58
|
|
71
|
-
};
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
componentDidMount(){
|
76
|
-
|
77
|
-
firebase.auth().onAuthStateChanged(function(user){
|
78
|
-
|
79
|
-
if(user){
|
80
|
-
|
81
|
-
this.props.history.push('/')
|
82
|
-
|
83
|
-
console.log(this.state.email, this.state.password)
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
else {
|
88
|
-
|
89
|
-
this.props.history.push('/login')
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
})
|
94
|
-
|
95
|
-
};
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
handleChange_email = (event) => {
|
100
|
-
|
101
|
-
this.setState({
|
102
|
-
|
103
|
-
email: event.target.value,
|
104
|
-
|
105
|
-
});
|
106
|
-
|
107
|
-
};
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
handleChange_password = (event) => {
|
112
|
-
|
113
|
-
this.setState({
|
114
|
-
|
115
|
-
password: event.target.value
|
116
|
-
|
117
|
-
});
|
118
|
-
|
119
|
-
};
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
onLoginBtnClick = (event) => {
|
124
|
-
|
125
|
-
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
126
|
-
|
127
|
-
};
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
render(){
|
132
|
-
|
133
|
-
return(
|
59
|
+
return (
|
134
60
|
|
135
61
|
<div>
|
136
62
|
|
137
|
-
<
|
63
|
+
<AppBar
|
138
64
|
|
139
|
-
id
|
65
|
+
title='plz donation'
|
140
66
|
|
141
|
-
|
67
|
+
iconElementRight={<SideLoginButton />}
|
142
68
|
|
143
|
-
f
|
69
|
+
onLeftIconButtonTouchTap={() =>
|
144
70
|
|
145
|
-
|
71
|
+
this.setState({ open: !this.state.open })}
|
146
72
|
|
147
|
-
|
73
|
+
/>
|
148
74
|
|
149
|
-
|
75
|
+
<Drawer
|
150
76
|
|
151
|
-
}
|
77
|
+
open={this.state.open}
|
152
78
|
|
153
|
-
|
79
|
+
docked={false}
|
154
80
|
|
155
|
-
|
81
|
+
onRequestChange={open => this.setState({ open })}
|
156
82
|
|
157
|
-
|
83
|
+
>
|
158
84
|
|
159
|
-
i
|
85
|
+
<List>
|
160
86
|
|
161
|
-
|
87
|
+
{links.map((link, i) => {
|
162
88
|
|
163
|
-
|
89
|
+
return (
|
164
90
|
|
165
|
-
|
91
|
+
<SideBarItem
|
166
92
|
|
167
|
-
|
93
|
+
isExact={link.isExact}
|
168
94
|
|
169
|
-
|
95
|
+
linkTo={link.linkTo}
|
170
96
|
|
171
|
-
|
97
|
+
primaryText={link.text}
|
172
98
|
|
173
|
-
|
99
|
+
onClick={this.handleClose}
|
174
100
|
|
175
|
-
|
101
|
+
key={i}
|
176
102
|
|
177
|
-
|
103
|
+
/>
|
178
104
|
|
179
|
-
|
105
|
+
)
|
180
106
|
|
107
|
+
})}
|
108
|
+
|
181
|
-
/>
|
109
|
+
</List>
|
110
|
+
|
111
|
+
</Drawer>
|
182
112
|
|
183
113
|
</div>
|
184
114
|
|
@@ -188,15 +118,29 @@
|
|
188
118
|
|
189
119
|
}
|
190
120
|
|
121
|
+
|
122
|
+
|
191
123
|
```
|
192
124
|
|
125
|
+
この、ログインボタンの部分を、ログイン中はログアウトボタンに変えたいです。ログイン中かどうかはrender外のfirebase.auth().onAuthStateChanged(function(user){
|
126
|
+
|
193
|
-
|
127
|
+
if(user){
|
194
128
|
|
195
129
|
|
196
130
|
|
131
|
+
}
|
132
|
+
|
197
|
-
|
133
|
+
else {
|
198
134
|
|
199
135
|
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
})
|
140
|
+
|
141
|
+
こいつで判別できるとして。
|
142
|
+
|
143
|
+
render内の<SideLoginButton/>を<LogoutBtn>に変えることってどうやれますか?
|
200
144
|
|
201
145
|
|
202
146
|
|
25
エラー更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,6 +72,30 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
+
componentDidMount(){
|
76
|
+
|
77
|
+
firebase.auth().onAuthStateChanged(function(user){
|
78
|
+
|
79
|
+
if(user){
|
80
|
+
|
81
|
+
this.props.history.push('/')
|
82
|
+
|
83
|
+
console.log(this.state.email, this.state.password)
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
else {
|
88
|
+
|
89
|
+
this.props.history.push('/login')
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
})
|
94
|
+
|
95
|
+
};
|
96
|
+
|
97
|
+
|
98
|
+
|
75
99
|
handleChange_email = (event) => {
|
76
100
|
|
77
101
|
this.setState({
|
@@ -100,24 +124,6 @@
|
|
100
124
|
|
101
125
|
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
102
126
|
|
103
|
-
console.log(this.state.email, this.state.password)
|
104
|
-
|
105
|
-
firebase.auth().onAuthStateChanged(function(user){
|
106
|
-
|
107
|
-
if(user){
|
108
|
-
|
109
|
-
this.props.history.push('/')
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
else {
|
114
|
-
|
115
|
-
this.props.history.push('/login')
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
})
|
120
|
-
|
121
127
|
};
|
122
128
|
|
123
129
|
|
@@ -188,7 +194,9 @@
|
|
188
194
|
|
189
195
|
|
190
196
|
|
191
|
-
|
197
|
+
historyが not defined
|
198
|
+
|
199
|
+
|
192
200
|
|
193
201
|
|
194
202
|
|
24
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,7 +58,15 @@
|
|
58
58
|
|
59
59
|
componentWillMount() {
|
60
60
|
|
61
|
+
var config = {
|
62
|
+
|
63
|
+
//中身は見せられません。個別FIrebase用ののキーです。
|
64
|
+
|
65
|
+
};
|
66
|
+
|
67
|
+
|
68
|
+
|
61
|
-
firebase.initializeApp()
|
69
|
+
firebase.initializeApp(config)
|
62
70
|
|
63
71
|
};
|
64
72
|
|
@@ -92,11 +100,7 @@
|
|
92
100
|
|
93
101
|
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
94
102
|
|
95
|
-
};
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
co
|
103
|
+
console.log(this.state.email, this.state.password)
|
100
104
|
|
101
105
|
firebase.auth().onAuthStateChanged(function(user){
|
102
106
|
|
@@ -164,7 +168,7 @@
|
|
164
168
|
|
165
169
|
label="Login"
|
166
170
|
|
167
|
-
se
|
171
|
+
secondary={true}
|
168
172
|
|
169
173
|
onClick={this.onLoginBtnClick}
|
170
174
|
|
@@ -180,9 +184,11 @@
|
|
180
184
|
|
181
185
|
```
|
182
186
|
|
187
|
+
とりあえずボタン押した時の分岐作成。
|
183
188
|
|
184
189
|
|
190
|
+
|
185
|
-
|
191
|
+
propsの二つ目が、Notdefinedとなるのですが、どうやって二つ目のprops?をうまく使えますか???
|
186
192
|
|
187
193
|
|
188
194
|
|
23
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,7 +88,7 @@
|
|
88
88
|
|
89
89
|
|
90
90
|
|
91
|
-
|
91
|
+
onLoginBtnClick = (event) => {
|
92
92
|
|
93
93
|
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
94
94
|
|
@@ -96,25 +96,25 @@
|
|
96
96
|
|
97
97
|
|
98
98
|
|
99
|
-
componentDidMount(){
|
99
|
+
componentDidMount(){
|
100
100
|
|
101
|
-
firebase.auth().onAuthStateChanged(function(user){
|
101
|
+
firebase.auth().onAuthStateChanged(function(user){
|
102
102
|
|
103
103
|
if(user){
|
104
104
|
|
105
|
-
|
105
|
+
this.props.history.push('/')
|
106
106
|
|
107
107
|
}
|
108
108
|
|
109
109
|
else {
|
110
110
|
|
111
|
-
|
111
|
+
this.props.history.push('/login')
|
112
112
|
|
113
113
|
}
|
114
114
|
|
115
|
-
})
|
115
|
+
})
|
116
116
|
|
117
|
-
};
|
117
|
+
};
|
118
118
|
|
119
119
|
|
120
120
|
|
@@ -166,7 +166,7 @@
|
|
166
166
|
|
167
167
|
sedondary={true}
|
168
168
|
|
169
|
-
onClick={this.
|
169
|
+
onClick={this.onLoginBtnClick}
|
170
170
|
|
171
171
|
/>
|
172
172
|
|
@@ -182,7 +182,7 @@
|
|
182
182
|
|
183
183
|
|
184
184
|
|
185
|
-
i
|
185
|
+
現在componentDidMount()に到達できていないことが判明。ボタン押した後に、この処理をさせるためにはどうしたらいいのでしょう。
|
186
186
|
|
187
187
|
|
188
188
|
|
22
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,11 +56,19 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
+
componentWillMount() {
|
60
|
+
|
61
|
+
firebase.initializeApp()
|
62
|
+
|
63
|
+
};
|
64
|
+
|
65
|
+
|
66
|
+
|
59
67
|
handleChange_email = (event) => {
|
60
68
|
|
61
69
|
this.setState({
|
62
70
|
|
63
|
-
email: event.target.
|
71
|
+
email: event.target.value,
|
64
72
|
|
65
73
|
});
|
66
74
|
|
@@ -72,7 +80,7 @@
|
|
72
80
|
|
73
81
|
this.setState({
|
74
82
|
|
75
|
-
password: event.target.
|
83
|
+
password: event.target.value
|
76
84
|
|
77
85
|
});
|
78
86
|
|
@@ -82,27 +90,31 @@
|
|
82
90
|
|
83
91
|
handleChange_button = (event) => {
|
84
92
|
|
85
|
-
firebase.initializeApp()
|
86
|
-
|
87
93
|
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
88
94
|
|
89
|
-
firebase.auth().onAuthStateChanged(function(user){
|
90
|
-
|
91
|
-
|
95
|
+
};
|
92
96
|
|
93
97
|
|
94
98
|
|
95
|
-
|
99
|
+
componentDidMount(){
|
96
100
|
|
101
|
+
firebase.auth().onAuthStateChanged(function(user){
|
102
|
+
|
97
|
-
|
103
|
+
if(user){
|
98
104
|
|
99
105
|
|
100
106
|
|
101
|
-
|
107
|
+
}
|
102
108
|
|
103
|
-
|
109
|
+
else {
|
104
110
|
|
111
|
+
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
})
|
116
|
+
|
105
|
-
|
117
|
+
};
|
106
118
|
|
107
119
|
|
108
120
|
|
@@ -170,7 +182,7 @@
|
|
170
182
|
|
171
183
|
|
172
184
|
|
173
|
-
if(user)で、
|
185
|
+
if(user)とelseで、別ファイルに記述した<Route>の内の一つに飛ばしたり、このページにリダイレクトしたり、したいです。
|
174
186
|
|
175
187
|
|
176
188
|
|
21
ルーティング
test
CHANGED
File without changes
|
test
CHANGED
@@ -86,6 +86,22 @@
|
|
86
86
|
|
87
87
|
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
88
88
|
|
89
|
+
firebase.auth().onAuthStateChanged(function(user){
|
90
|
+
|
91
|
+
if(user){
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
else {
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
})
|
104
|
+
|
89
105
|
};
|
90
106
|
|
91
107
|
|
@@ -106,6 +122,12 @@
|
|
106
122
|
|
107
123
|
onChange={this.handleChange_email}
|
108
124
|
|
125
|
+
style={{
|
126
|
+
|
127
|
+
margin: '0 auto',
|
128
|
+
|
129
|
+
}}
|
130
|
+
|
109
131
|
/>
|
110
132
|
|
111
133
|
<br />
|
@@ -122,7 +144,7 @@
|
|
122
144
|
|
123
145
|
onChange={this.handleChange_password}
|
124
146
|
|
125
|
-
/>
|
147
|
+
/>
|
126
148
|
|
127
149
|
<br />
|
128
150
|
|
@@ -134,7 +156,7 @@
|
|
134
156
|
|
135
157
|
onClick={this.handleChange_button}
|
136
158
|
|
137
|
-
/>
|
159
|
+
/>
|
138
160
|
|
139
161
|
</div>
|
140
162
|
|
@@ -148,7 +170,7 @@
|
|
148
170
|
|
149
171
|
|
150
172
|
|
151
|
-
|
173
|
+
if(user)で、それぞれ別の URLに飛ばせるようにしたいのですが、render外で書く方法がわかりません。
|
152
174
|
|
153
175
|
|
154
176
|
|
20
次の課題
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
---
|
36
36
|
|
37
|
-
|
37
|
+
|
38
38
|
|
39
39
|
```js
|
40
40
|
|
@@ -46,9 +46,9 @@
|
|
46
46
|
|
47
47
|
this.state = {
|
48
48
|
|
49
|
-
email: '
|
49
|
+
email: '',
|
50
50
|
|
51
|
-
password:'
|
51
|
+
password:''
|
52
52
|
|
53
53
|
};
|
54
54
|
|
@@ -82,11 +82,9 @@
|
|
82
82
|
|
83
83
|
handleChange_button = (event) => {
|
84
84
|
|
85
|
-
|
85
|
+
firebase.initializeApp()
|
86
86
|
|
87
|
-
|
87
|
+
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
88
|
-
|
89
|
-
});
|
90
88
|
|
91
89
|
};
|
92
90
|
|
@@ -104,6 +102,8 @@
|
|
104
102
|
|
105
103
|
value={this.state.email}
|
106
104
|
|
105
|
+
floatingLabelText="UserID"
|
106
|
+
|
107
107
|
onChange={this.handleChange_email}
|
108
108
|
|
109
109
|
/>
|
@@ -115,6 +115,8 @@
|
|
115
115
|
id="passwordform"
|
116
116
|
|
117
117
|
value={this.state.password}
|
118
|
+
|
119
|
+
floatingLabelText="password"
|
118
120
|
|
119
121
|
type='password'
|
120
122
|
|
@@ -146,7 +148,7 @@
|
|
146
148
|
|
147
149
|
|
148
150
|
|
149
|
-
|
151
|
+
次はログイン状態の確認と、ログイン状態の画面遷移の作成します。
|
150
152
|
|
151
153
|
|
152
154
|
|
19
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,6 +80,16 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
+
handleChange_button = (event) => {
|
84
|
+
|
85
|
+
this.setState({
|
86
|
+
|
87
|
+
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
|
88
|
+
|
89
|
+
});
|
90
|
+
|
91
|
+
};
|
92
|
+
|
83
93
|
|
84
94
|
|
85
95
|
render(){
|
@@ -90,9 +100,9 @@
|
|
90
100
|
|
91
101
|
<TextField
|
92
102
|
|
93
|
-
id="
|
103
|
+
id="emailform"
|
94
104
|
|
95
|
-
|
105
|
+
value={this.state.email}
|
96
106
|
|
97
107
|
onChange={this.handleChange_email}
|
98
108
|
|
@@ -102,9 +112,9 @@
|
|
102
112
|
|
103
113
|
<TextField
|
104
114
|
|
105
|
-
id="
|
115
|
+
id="passwordform"
|
106
116
|
|
107
|
-
|
117
|
+
value={this.state.password}
|
108
118
|
|
109
119
|
type='password'
|
110
120
|
|
@@ -120,9 +130,7 @@
|
|
120
130
|
|
121
131
|
sedondary={true}
|
122
132
|
|
123
|
-
|
124
|
-
|
125
|
-
onClick={
|
133
|
+
onClick={this.handleChange_button}
|
126
134
|
|
127
135
|
/>
|
128
136
|
|
@@ -138,9 +146,7 @@
|
|
138
146
|
|
139
147
|
|
140
148
|
|
141
|
-
|
142
|
-
|
143
|
-
|
149
|
+
firebaseの.が怒られます
|
144
150
|
|
145
151
|
|
146
152
|
|
18
説明修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,7 +136,11 @@
|
|
136
136
|
|
137
137
|
```
|
138
138
|
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
139
|
-
|
143
|
+
index.jsのReactDOM.render(<App />, document.getElementById('root'))とfirebaseがreact-scripts start上で怒られます
|
140
144
|
|
141
145
|
|
142
146
|
|
17
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,6 +80,8 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
+
|
84
|
+
|
83
85
|
render(){
|
84
86
|
|
85
87
|
return(
|
@@ -118,7 +120,9 @@
|
|
118
120
|
|
119
121
|
sedondary={true}
|
120
122
|
|
123
|
+
|
124
|
+
|
121
|
-
onClick={firebase.auth().signInWithEmailAndPassword(email, password)}
|
125
|
+
onClick={firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)}
|
122
126
|
|
123
127
|
/>
|
124
128
|
|
16
handleChange分離しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,11 +56,21 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
handleChange = (event) => {
|
59
|
+
handleChange_email = (event) => {
|
60
60
|
|
61
61
|
this.setState({
|
62
62
|
|
63
63
|
email: event.target.email,
|
64
|
+
|
65
|
+
});
|
66
|
+
|
67
|
+
};
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
handleChange_password = (event) => {
|
72
|
+
|
73
|
+
this.setState({
|
64
74
|
|
65
75
|
password: event.target.password
|
66
76
|
|
@@ -82,7 +92,7 @@
|
|
82
92
|
|
83
93
|
email={this.state.email}
|
84
94
|
|
85
|
-
onChange={this.handleChange}
|
95
|
+
onChange={this.handleChange_email}
|
86
96
|
|
87
97
|
/>
|
88
98
|
|
@@ -96,7 +106,7 @@
|
|
96
106
|
|
97
107
|
type='password'
|
98
108
|
|
99
|
-
onChange={this.handleChange}
|
109
|
+
onChange={this.handleChange_password}
|
100
110
|
|
101
111
|
/>
|
102
112
|
|
@@ -122,15 +132,7 @@
|
|
122
132
|
|
123
133
|
```
|
124
134
|
|
125
|
-
|
135
|
+
現在emailとpasswordがnotdefined
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
handleChangeで二つの変数を同時に扱えるのかなと思いましたがどうなんでしょうか?
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
textfieldそれぞれに別のclassを作成してあげて、最後にコンポーネントとして使用した方がいいのでしょうか?
|
134
136
|
|
135
137
|
|
136
138
|
|
15
とりあえずonChange
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,6 +82,8 @@
|
|
82
82
|
|
83
83
|
email={this.state.email}
|
84
84
|
|
85
|
+
onChange={this.handleChange}
|
86
|
+
|
85
87
|
/>
|
86
88
|
|
87
89
|
<br />
|
@@ -93,6 +95,8 @@
|
|
93
95
|
password={this.state.password}
|
94
96
|
|
95
97
|
type='password'
|
98
|
+
|
99
|
+
onChange={this.handleChange}
|
96
100
|
|
97
101
|
/>
|
98
102
|
|
14
あああ
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,13 +104,13 @@
|
|
104
104
|
|
105
105
|
sedondary={true}
|
106
106
|
|
107
|
+
onClick={firebase.auth().signInWithEmailAndPassword(email, password)}
|
108
|
+
|
107
109
|
/>
|
108
110
|
|
109
111
|
</div>
|
110
112
|
|
111
113
|
)
|
112
|
-
|
113
|
-
firebase.auth().signInWithEmailAndPassword(email, password)
|
114
114
|
|
115
115
|
}
|
116
116
|
|
13
a
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,6 +98,14 @@
|
|
98
98
|
|
99
99
|
<br />
|
100
100
|
|
101
|
+
<RaisedButton
|
102
|
+
|
103
|
+
label="Login"
|
104
|
+
|
105
|
+
sedondary={true}
|
106
|
+
|
107
|
+
/>
|
108
|
+
|
101
109
|
</div>
|
102
110
|
|
103
111
|
)
|
@@ -107,8 +115,6 @@
|
|
107
115
|
}
|
108
116
|
|
109
117
|
}
|
110
|
-
|
111
|
-
export default Login
|
112
118
|
|
113
119
|
```
|
114
120
|
|
12
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -70,43 +70,43 @@
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
render(){
|
73
|
+
render(){
|
74
74
|
|
75
|
-
return(
|
75
|
+
return(
|
76
76
|
|
77
|
-
<div>
|
77
|
+
<div>
|
78
78
|
|
79
|
-
<TextField
|
79
|
+
<TextField
|
80
80
|
|
81
|
-
id="text-field-controlled"
|
81
|
+
id="text-field-controlled"
|
82
82
|
|
83
|
-
email={this.state.email}
|
83
|
+
email={this.state.email}
|
84
84
|
|
85
|
-
/>
|
85
|
+
/>
|
86
86
|
|
87
|
-
<br />
|
87
|
+
<br />
|
88
88
|
|
89
|
-
<TextField
|
89
|
+
<TextField
|
90
90
|
|
91
|
-
id="text-field-controlled"
|
91
|
+
id="text-field-controlled"
|
92
92
|
|
93
|
-
password={this.state.password}
|
93
|
+
password={this.state.password}
|
94
94
|
|
95
|
-
type='password'
|
95
|
+
type='password'
|
96
96
|
|
97
|
-
/>
|
97
|
+
/>
|
98
98
|
|
99
|
-
<br />
|
99
|
+
<br />
|
100
100
|
|
101
|
-
</div>
|
101
|
+
</div>
|
102
102
|
|
103
|
-
)
|
103
|
+
)
|
104
|
+
|
105
|
+
firebase.auth().signInWithEmailAndPassword(email, password)
|
106
|
+
|
107
|
+
}
|
104
108
|
|
105
109
|
}
|
106
|
-
|
107
|
-
firebase.auth().signInWithEmailAndPassword(email, password)
|
108
|
-
|
109
|
-
|
110
110
|
|
111
111
|
export default Login
|
112
112
|
|
11
詳細
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,91 @@
|
|
36
36
|
|
37
37
|
テキストボックスから受け取った内容を変数に入れて、関数に渡すやり方がわかりません。
|
38
38
|
|
39
|
+
```js
|
39
40
|
|
41
|
+
class Login extends Component{
|
42
|
+
|
43
|
+
constructor (props) {
|
44
|
+
|
45
|
+
super(props)
|
46
|
+
|
47
|
+
this.state = {
|
48
|
+
|
49
|
+
email: 'User ID',
|
50
|
+
|
51
|
+
password:'Password'
|
52
|
+
|
53
|
+
};
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
handleChange = (event) => {
|
60
|
+
|
61
|
+
this.setState({
|
62
|
+
|
63
|
+
email: event.target.email,
|
64
|
+
|
65
|
+
password: event.target.password
|
66
|
+
|
67
|
+
});
|
68
|
+
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
render(){
|
74
|
+
|
75
|
+
return(
|
76
|
+
|
77
|
+
<div>
|
78
|
+
|
79
|
+
<TextField
|
80
|
+
|
81
|
+
id="text-field-controlled"
|
82
|
+
|
83
|
+
email={this.state.email}
|
84
|
+
|
85
|
+
/>
|
86
|
+
|
87
|
+
<br />
|
88
|
+
|
89
|
+
<TextField
|
90
|
+
|
91
|
+
id="text-field-controlled"
|
92
|
+
|
93
|
+
password={this.state.password}
|
94
|
+
|
95
|
+
type='password'
|
96
|
+
|
97
|
+
/>
|
98
|
+
|
99
|
+
<br />
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
)
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
firebase.auth().signInWithEmailAndPassword(email, password)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
export default Login
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
自分のイメージとしてはこれで、emailとpasswordの値を取得して代入するところまでは作れたつもりです。
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
handleChangeで二つの変数を同時に扱えるのかなと思いましたがどうなんでしょうか?
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
textfieldそれぞれに別のclassを作成してあげて、最後にコンポーネントとして使用した方がいいのでしょうか?
|
40
124
|
|
41
125
|
|
42
126
|
|
10
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,50 +30,14 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
-
|
33
|
+
不明点
|
34
34
|
|
35
35
|
---
|
36
36
|
|
37
|
-
|
37
|
+
テキストボックスから受け取った内容を変数に入れて、関数に渡すやり方がわかりません。
|
38
38
|
|
39
39
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
-
```git commit
|
44
|
-
|
45
|
-
husky > npm run -s precommit (node v6.11.2)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
✔ Running tasks for *.js
|
50
|
-
|
51
|
-
Error: ENOENT: no such file or directory, open '/Users/owner/works/plz_donation/{"collectCoverageFrom":["src/**/*.{js,jsx}"],"setupFiles":["/Users/owner/works/plz_donation/node_modules/react-scripts/config/polyfills.js"],"testMatch":["<rootDir>/src/**/__tests__/**/*.js?(x)","<rootDir>/src/**/?(*.)(spec|test).js?(x)"],"testEnvironment":"node","testURL":"http:/localhost","transform":{"^.+\.(js|jsx)$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/babelTransform.js","^.+\.css$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/cssTransform.js","^(?!.*\.(js|jsx|css|json)$)":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/fileTransform.js"},"transformIgnorePatterns":["[/\\]node_modules[/\\].+\.(js|jsx)$"],"moduleNameMapper":{"^react-native$":"react-native-web"},"moduleFileExtensions":["web.js","js","json","web.jsx","jsx"],"rootDir":"/Users/owner/works/plz_donation"}'
|
52
|
-
|
53
|
-
at Error (native)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
husky > pre-commit hook failed (add --no-verify to bypass)
|
58
|
-
|
59
|
-
MurakaminoMacBook-Pro:plz_donation owner$ git commit -m "add login view"
|
60
|
-
|
61
|
-
husky > npm run -s precommit (node v6.11.2)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
✔ Running tasks for *.js
|
66
|
-
|
67
|
-
Error: ENOENT: no such file or directory, open '/Users/owner/works/plz_donation/{"collectCoverageFrom":["src/**/*.{js,jsx}"],"setupFiles":["/Users/owner/works/plz_donation/node_modules/react-scripts/config/polyfills.js"],"testMatch":["<rootDir>/src/**/__tests__/**/*.js?(x)","<rootDir>/src/**/?(*.)(spec|test).js?(x)"],"testEnvironment":"node","testURL":"http:/localhost","transform":{"^.+\.(js|jsx)$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/babelTransform.js","^.+\.css$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/cssTransform.js","^(?!.*\.(js|jsx|css|json)$)":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/fileTransform.js"},"transformIgnorePatterns":["[/\\]node_modules[/\\].+\.(js|jsx)$"],"moduleNameMapper":{"^react-native$":"react-native-web"},"moduleFileExtensions":["web.js","js","json","web.jsx","jsx"],"rootDir":"/Users/owner/works/plz_donation"}'
|
68
|
-
|
69
|
-
at Error (native)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
husky > pre-commit hook failed (add --no-verify to bypass)
|
74
|
-
|
75
|
-
```
|
76
|
-
|
77
|
-
|
78
|
-
|
79
43
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
9
指針変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,37 +24,7 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
-
[ユーザー認証参考ブログ](https://qiita.com/suin/items/b7275ff3eb3486380c7e)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
エラー履歴①
|
32
|
-
|
33
|
-
---
|
34
|
-
|
35
|
-
ブログサンプルコンパイルエラー
|
36
|
-
|
37
|
-
●解決しました。@の正体はデコレーター。
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
エラー履歴②
|
42
|
-
|
43
|
-
---
|
44
|
-
|
45
|
-
reduxわからなすぎるので、
|
46
|
-
|
47
|
-
●reduxを消し、解決しました。
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
エラー履歴③
|
52
|
-
|
53
|
-
---
|
54
|
-
|
55
|
-
|
27
|
+
現在、ユーザー認証はFirebase経由で行います。
|
56
|
-
|
57
|
-
[ここ](https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes)より修正。
|
58
28
|
|
59
29
|
|
60
30
|
|
@@ -64,310 +34,46 @@
|
|
64
34
|
|
65
35
|
---
|
66
36
|
|
67
|
-
コンパイルは可能。react-scripts start後のエラー。
|
68
|
-
|
69
|
-
長すぎるのでまず最初。
|
70
|
-
|
71
|
-
```ERROR
|
72
|
-
|
73
|
-
TypeError: Cannot call a class as a function
|
74
|
-
|
75
|
-
_classCallCheck
|
76
|
-
|
77
|
-
http://localhost:3000/static/js/bundle.js:67386:99
|
78
|
-
|
79
|
-
UserOnly
|
80
|
-
|
81
|
-
http://localhost:3000/static/js/bundle.js:67393:5
|
82
|
-
|
83
|
-
(anonymous function)
|
84
|
-
|
85
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:305
|
86
|
-
|
87
|
-
302 | // but we'll count this as time spent rendering as the more common case.
|
88
|
-
|
89
|
-
303 | if (process.env.NODE_ENV !== 'production') {
|
90
|
-
|
91
|
-
304 | return measureLifeCyclePerf(function () {
|
92
|
-
|
93
|
-
> 305 | return Component(publicProps, publicContext, updateQueue);
|
94
|
-
|
95
|
-
306 | }, this._debugID, 'render');
|
96
|
-
|
97
|
-
307 | } else {
|
98
|
-
|
99
|
-
308 | return Component(publicProps, publicContext, updateQueue);
|
100
|
-
|
101
|
-
View compiled
|
102
|
-
|
103
|
-
measureLifeCyclePerf
|
104
|
-
|
105
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:75
|
106
|
-
|
107
|
-
72 |
|
108
|
-
|
109
|
-
73 | ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID, timerType);
|
110
|
-
|
111
|
-
74 | try {
|
112
|
-
|
113
|
-
> 75 | return fn();
|
114
|
-
|
115
|
-
76 | } finally {
|
116
|
-
|
117
|
-
77 | ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID, timerType);
|
118
|
-
|
119
|
-
78 | }
|
120
|
-
|
121
|
-
View compiled
|
122
|
-
|
123
|
-
ReactCompositeComponentWrapper._constructComponentWithoutOwner
|
124
|
-
|
125
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:304
|
126
|
-
|
127
|
-
301 | // This can still be an instance in case of factory components
|
128
|
-
|
129
|
-
302 | // but we'll count this as time spent rendering as the more common case.
|
130
|
-
|
131
|
-
303 | if (process.env.NODE_ENV !== 'production') {
|
132
|
-
|
133
|
-
> 304 | return measureLifeCyclePerf(function () {
|
134
|
-
|
135
|
-
305 | return Component(publicProps, publicContext, updateQueue);
|
136
|
-
|
137
|
-
306 | }, this._debugID, 'render');
|
138
|
-
|
139
|
-
307 | } else {
|
140
|
-
|
141
|
-
View compiled
|
142
|
-
|
143
|
-
ReactCompositeComponentWrapper._constructComponent
|
144
|
-
|
145
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:279
|
146
|
-
|
147
|
-
276 | if (process.env.NODE_ENV !== 'production') {
|
148
|
-
|
149
|
-
277 | ReactCurrentOwner.current = this;
|
150
|
-
|
151
|
-
278 | try {
|
152
|
-
|
153
|
-
> 279 | return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
|
154
|
-
|
155
|
-
280 | } finally {
|
156
|
-
|
157
|
-
281 | ReactCurrentOwner.current = null;
|
158
|
-
|
159
|
-
282 | }
|
160
|
-
|
161
|
-
View compiled
|
162
|
-
|
163
|
-
ReactCompositeComponentWrapper.mountComponent
|
164
|
-
|
165
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:187
|
166
|
-
|
167
|
-
184 |
|
168
|
-
|
169
|
-
185 | // Initialize the public class
|
170
|
-
|
171
|
-
186 | var doConstruct = shouldConstruct(Component);
|
172
|
-
|
173
|
-
> 187 | var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
|
174
|
-
|
175
|
-
188 | var renderedElement;
|
176
|
-
|
177
|
-
189 |
|
178
|
-
|
179
|
-
190 | // Support functional components
|
180
|
-
|
181
|
-
View compiled
|
182
|
-
|
183
|
-
Object.mountComponent
|
184
|
-
|
185
|
-
node_modules/react-dom/lib/ReactReconciler.js:45
|
186
|
-
|
187
|
-
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
188
|
-
|
189
|
-
43 | }
|
190
|
-
|
191
|
-
44 | }
|
192
|
-
|
193
|
-
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
194
|
-
|
195
|
-
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
196
|
-
|
197
|
-
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
198
|
-
|
199
|
-
48 | }
|
200
|
-
|
201
|
-
View compiled
|
202
|
-
|
203
|
-
ReactCompositeComponentWrapper.performInitialMount
|
204
|
-
|
205
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:370
|
206
|
-
|
207
|
-
367 | );
|
208
|
-
|
209
|
-
368 | this._renderedComponent = child;
|
210
|
-
|
211
|
-
369 |
|
212
|
-
|
213
|
-
> 370 | var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
|
214
|
-
|
215
|
-
371 |
|
216
|
-
|
217
|
-
372 | if (process.env.NODE_ENV !== 'production') {
|
218
|
-
|
219
|
-
373 | if (debugID !== 0) {
|
220
|
-
|
221
|
-
View compiled
|
222
|
-
|
223
|
-
ReactCompositeComponentWrapper.mountComponent
|
224
|
-
|
225
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:257
|
226
|
-
|
227
|
-
|
37
|
+
git commit がエラーに。。 git add まではできました。
|
228
|
-
|
229
|
-
255 | markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
230
|
-
|
231
|
-
256 | } else {
|
232
|
-
|
233
|
-
> 257 | markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
234
|
-
|
235
|
-
258 | }
|
236
|
-
|
237
|
-
259 |
|
238
|
-
|
239
|
-
260 | if (inst.componentDidMount) {
|
240
|
-
|
241
|
-
View compiled
|
242
|
-
|
243
|
-
Object.mountComponent
|
244
|
-
|
245
|
-
node_modules/react-dom/lib/ReactReconciler.js:45
|
246
|
-
|
247
|
-
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
248
|
-
|
249
|
-
43 | }
|
250
|
-
|
251
|
-
44 | }
|
252
|
-
|
253
|
-
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
254
|
-
|
255
|
-
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
256
|
-
|
257
|
-
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
258
|
-
|
259
|
-
48 | }
|
260
|
-
|
261
|
-
View compiled
|
262
|
-
|
263
|
-
ReactCompositeComponentWrapper.performInitialMount
|
264
|
-
|
265
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:370
|
266
|
-
|
267
|
-
367 | );
|
268
|
-
|
269
|
-
368 | this._renderedComponent = child;
|
270
|
-
|
271
|
-
369 |
|
272
|
-
|
273
|
-
> 370 | var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
|
274
|
-
|
275
|
-
371 |
|
276
|
-
|
277
|
-
372 | if (process.env.NODE_ENV !== 'production') {
|
278
|
-
|
279
|
-
373 | if (debugID !== 0) {
|
280
|
-
|
281
|
-
View compiled
|
282
|
-
|
283
|
-
ReactCompositeComponentWrapper.mountComponent
|
284
|
-
|
285
|
-
node_modules/react-dom/lib/ReactCompositeComponent.js:257
|
286
|
-
|
287
|
-
254 | if (inst.unstable_handleError) {
|
288
|
-
|
289
|
-
255 | markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
290
|
-
|
291
|
-
256 | } else {
|
292
|
-
|
293
|
-
> 257 | markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
294
|
-
|
295
|
-
258 | }
|
296
|
-
|
297
|
-
259 |
|
298
|
-
|
299
|
-
260 | if (inst.componentDidMount) {
|
300
|
-
|
301
|
-
View compiled
|
302
|
-
|
303
|
-
Object.mountComponent
|
304
|
-
|
305
|
-
node_modules/react-dom/lib/ReactReconciler.js:45
|
306
|
-
|
307
|
-
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
308
|
-
|
309
|
-
43 | }
|
310
|
-
|
311
|
-
44 | }
|
312
|
-
|
313
|
-
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
314
|
-
|
315
|
-
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
316
|
-
|
317
|
-
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
318
|
-
|
319
|
-
48 | }
|
320
|
-
|
321
|
-
View compiled
|
322
|
-
|
323
|
-
ReactDOMComponent.mountChildren
|
324
|
-
|
325
|
-
node_modules/react-dom/lib/ReactMultiChild.js:236
|
326
|
-
|
327
|
-
233 | if (process.env.NODE_ENV !== 'production') {
|
328
|
-
|
329
|
-
234 | selfDebugID = getDebugID(this);
|
330
|
-
|
331
|
-
235 | }
|
332
|
-
|
333
|
-
> 236 | var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);
|
334
|
-
|
335
|
-
237 | child._mountIndex = index++;
|
336
|
-
|
337
|
-
238 | mountImages.push(mountImage);
|
338
|
-
|
339
|
-
239 | }
|
340
|
-
|
341
|
-
View compiled
|
342
|
-
|
343
|
-
ReactDOMComponent._createInitialChildren
|
344
|
-
|
345
|
-
node_modules/react-dom/lib/ReactDOMComponent.js:703
|
346
|
-
|
347
|
-
700 | DOMLazyTree.queueText(lazyTree, contentToUse);
|
348
|
-
|
349
|
-
701 | }
|
350
|
-
|
351
|
-
702 | } else if (childrenToUse != null) {
|
352
|
-
|
353
|
-
> 703 | var mountImages = this.mountChildren(childrenToUse, transaction, context);
|
354
|
-
|
355
|
-
704 | for (var i = 0; i < mountImages.length; i++) {
|
356
|
-
|
357
|
-
705 | DOMLazyTree.queueChild(lazyTree, mountImages[i]);
|
358
|
-
|
359
|
-
706 | }
|
360
38
|
|
361
39
|
|
362
40
|
|
363
41
|
|
364
42
|
|
43
|
+
```git commit
|
44
|
+
|
45
|
+
husky > npm run -s precommit (node v6.11.2)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
✔ Running tasks for *.js
|
50
|
+
|
51
|
+
Error: ENOENT: no such file or directory, open '/Users/owner/works/plz_donation/{"collectCoverageFrom":["src/**/*.{js,jsx}"],"setupFiles":["/Users/owner/works/plz_donation/node_modules/react-scripts/config/polyfills.js"],"testMatch":["<rootDir>/src/**/__tests__/**/*.js?(x)","<rootDir>/src/**/?(*.)(spec|test).js?(x)"],"testEnvironment":"node","testURL":"http:/localhost","transform":{"^.+\.(js|jsx)$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/babelTransform.js","^.+\.css$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/cssTransform.js","^(?!.*\.(js|jsx|css|json)$)":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/fileTransform.js"},"transformIgnorePatterns":["[/\\]node_modules[/\\].+\.(js|jsx)$"],"moduleNameMapper":{"^react-native$":"react-native-web"},"moduleFileExtensions":["web.js","js","json","web.jsx","jsx"],"rootDir":"/Users/owner/works/plz_donation"}'
|
52
|
+
|
53
|
+
at Error (native)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
husky > pre-commit hook failed (add --no-verify to bypass)
|
58
|
+
|
59
|
+
MurakaminoMacBook-Pro:plz_donation owner$ git commit -m "add login view"
|
60
|
+
|
61
|
+
husky > npm run -s precommit (node v6.11.2)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
✔ Running tasks for *.js
|
66
|
+
|
67
|
+
Error: ENOENT: no such file or directory, open '/Users/owner/works/plz_donation/{"collectCoverageFrom":["src/**/*.{js,jsx}"],"setupFiles":["/Users/owner/works/plz_donation/node_modules/react-scripts/config/polyfills.js"],"testMatch":["<rootDir>/src/**/__tests__/**/*.js?(x)","<rootDir>/src/**/?(*.)(spec|test).js?(x)"],"testEnvironment":"node","testURL":"http:/localhost","transform":{"^.+\.(js|jsx)$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/babelTransform.js","^.+\.css$":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/cssTransform.js","^(?!.*\.(js|jsx|css|json)$)":"/Users/owner/works/plz_donation/node_modules/react-scripts/config/jest/fileTransform.js"},"transformIgnorePatterns":["[/\\]node_modules[/\\].+\.(js|jsx)$"],"moduleNameMapper":{"^react-native$":"react-native-web"},"moduleFileExtensions":["web.js","js","json","web.jsx","jsx"],"rootDir":"/Users/owner/works/plz_donation"}'
|
68
|
+
|
69
|
+
at Error (native)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
husky > pre-commit hook failed (add --no-verify to bypass)
|
74
|
+
|
365
75
|
```
|
366
76
|
|
367
77
|
|
368
78
|
|
369
|
-
redux騒動でバージョンが変わったせいでしょうか。たくさんエラーです。
|
370
|
-
|
371
|
-
|
372
|
-
|
373
79
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
8
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
---
|
66
66
|
|
67
|
-
コンパイルは可能。react
|
67
|
+
コンパイルは可能。react-scripts start後のエラー。
|
68
68
|
|
69
69
|
長すぎるのでまず最初。
|
70
70
|
|
7
ランチャー修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
テストサーバーはreact
|
23
|
+
テストサーバーはreact-scripts startにて。
|
24
24
|
|
25
25
|
|
26
26
|
|
6
ネクストエラー
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,25 +4,15 @@
|
|
4
4
|
|
5
5
|
- 搭載したい機能リスト
|
6
6
|
|
7
|
-
|
7
|
+
進行中→ ●ユーザー認証
|
8
|
-
|
8
|
+
|
9
|
-
ーー(ページごとにユーザーのみ、ゲストのみと分けたい。)
|
9
|
+
ーー(ページごとにユーザーのみ、ゲストのみと分けたい。)
|
10
|
-
|
10
|
+
|
11
|
-
・ゲスト、ユーザーが見れるプラットホーム。
|
11
|
+
・ゲスト、ユーザーが見れるプラットホーム。
|
12
|
-
|
12
|
+
|
13
|
-
ーー(ユーザーが投稿した内容が時系列で表示)
|
13
|
+
ーー(ユーザーが投稿した内容が時系列で表示)
|
14
|
-
|
14
|
+
|
15
|
-
・ユーザー課金、ゲスト課金とかも導入したい。
|
15
|
+
・ユーザー課金、ゲスト課金とかも導入したい。
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
この辺りの機能の名前がわからなくて、調べられなかったり、jsx記述のブログばかりで、思ったように解決できずに困っています。
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
16
|
|
27
17
|
|
28
18
|
|
@@ -30,107 +20,353 @@
|
|
30
20
|
|
31
21
|
|
32
22
|
|
33
|
-
|
34
|
-
|
35
23
|
テストサーバーはreactのランチャー
|
36
24
|
|
37
25
|
|
38
26
|
|
27
|
+
[ユーザー認証参考ブログ](https://qiita.com/suin/items/b7275ff3eb3486380c7e)
|
28
|
+
|
39
29
|
|
40
30
|
|
41
31
|
エラー履歴①
|
42
32
|
|
43
33
|
---
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
35
|
+
ブログサンプルコンパイルエラー
|
36
|
+
|
37
|
+
●解決しました。@の正体はデコレーター。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
エラー履歴②
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
reduxわからなすぎるので、
|
46
|
+
|
47
|
+
●reduxを消し、解決しました。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
エラー履歴③
|
52
|
+
|
53
|
+
---
|
54
|
+
|
55
|
+
Proptypesがバージョン変更により不能だった。
|
56
|
+
|
57
|
+
[ここ](https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes)より修正。
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
目下エラー
|
64
|
+
|
65
|
+
---
|
66
|
+
|
67
|
+
コンパイルは可能。reactランチャー上でのエラー。
|
68
|
+
|
69
|
+
長すぎるのでまず最初。
|
70
|
+
|
71
|
+
```ERROR
|
72
|
+
|
73
|
+
TypeError: Cannot call a class as a function
|
74
|
+
|
75
|
+
_classCallCheck
|
76
|
+
|
77
|
+
http://localhost:3000/static/js/bundle.js:67386:99
|
78
|
+
|
79
|
+
UserOnly
|
80
|
+
|
81
|
+
http://localhost:3000/static/js/bundle.js:67393:5
|
82
|
+
|
83
|
+
(anonymous function)
|
84
|
+
|
85
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:305
|
86
|
+
|
87
|
+
302 | // but we'll count this as time spent rendering as the more common case.
|
88
|
+
|
89
|
+
303 | if (process.env.NODE_ENV !== 'production') {
|
90
|
+
|
91
|
+
304 | return measureLifeCyclePerf(function () {
|
92
|
+
|
93
|
+
> 305 | return Component(publicProps, publicContext, updateQueue);
|
94
|
+
|
95
|
+
306 | }, this._debugID, 'render');
|
96
|
+
|
97
|
+
307 | } else {
|
98
|
+
|
99
|
+
308 | return Component(publicProps, publicContext, updateQueue);
|
100
|
+
|
101
|
+
View compiled
|
102
|
+
|
103
|
+
measureLifeCyclePerf
|
104
|
+
|
105
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:75
|
106
|
+
|
107
|
+
72 |
|
108
|
+
|
109
|
+
73 | ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID, timerType);
|
110
|
+
|
111
|
+
74 | try {
|
112
|
+
|
113
|
+
> 75 | return fn();
|
114
|
+
|
115
|
+
76 | } finally {
|
116
|
+
|
117
|
+
77 | ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID, timerType);
|
118
|
+
|
119
|
+
78 | }
|
120
|
+
|
121
|
+
View compiled
|
122
|
+
|
123
|
+
ReactCompositeComponentWrapper._constructComponentWithoutOwner
|
124
|
+
|
125
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:304
|
126
|
+
|
127
|
+
301 | // This can still be an instance in case of factory components
|
128
|
+
|
129
|
+
302 | // but we'll count this as time spent rendering as the more common case.
|
130
|
+
|
131
|
+
303 | if (process.env.NODE_ENV !== 'production') {
|
132
|
+
|
133
|
+
> 304 | return measureLifeCyclePerf(function () {
|
134
|
+
|
135
|
+
305 | return Component(publicProps, publicContext, updateQueue);
|
136
|
+
|
137
|
+
306 | }, this._debugID, 'render');
|
138
|
+
|
139
|
+
307 | } else {
|
140
|
+
|
141
|
+
View compiled
|
142
|
+
|
143
|
+
ReactCompositeComponentWrapper._constructComponent
|
144
|
+
|
145
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:279
|
146
|
+
|
147
|
+
276 | if (process.env.NODE_ENV !== 'production') {
|
148
|
+
|
149
|
+
277 | ReactCurrentOwner.current = this;
|
150
|
+
|
151
|
+
278 | try {
|
152
|
+
|
153
|
+
> 279 | return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
|
154
|
+
|
155
|
+
280 | } finally {
|
156
|
+
|
157
|
+
281 | ReactCurrentOwner.current = null;
|
158
|
+
|
159
|
+
282 | }
|
160
|
+
|
161
|
+
View compiled
|
162
|
+
|
163
|
+
ReactCompositeComponentWrapper.mountComponent
|
164
|
+
|
165
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:187
|
166
|
+
|
167
|
+
184 |
|
168
|
+
|
169
|
+
185 | // Initialize the public class
|
170
|
+
|
171
|
+
186 | var doConstruct = shouldConstruct(Component);
|
172
|
+
|
173
|
+
> 187 | var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
|
174
|
+
|
175
|
+
188 | var renderedElement;
|
176
|
+
|
177
|
+
189 |
|
178
|
+
|
179
|
+
190 | // Support functional components
|
180
|
+
|
181
|
+
View compiled
|
182
|
+
|
183
|
+
Object.mountComponent
|
184
|
+
|
185
|
+
node_modules/react-dom/lib/ReactReconciler.js:45
|
186
|
+
|
187
|
+
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
188
|
+
|
189
|
+
43 | }
|
190
|
+
|
191
|
+
44 | }
|
192
|
+
|
193
|
+
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
194
|
+
|
195
|
+
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
196
|
+
|
197
|
+
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
198
|
+
|
199
|
+
48 | }
|
200
|
+
|
201
|
+
View compiled
|
202
|
+
|
203
|
+
ReactCompositeComponentWrapper.performInitialMount
|
204
|
+
|
205
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:370
|
206
|
+
|
207
|
+
367 | );
|
208
|
+
|
209
|
+
368 | this._renderedComponent = child;
|
210
|
+
|
211
|
+
369 |
|
212
|
+
|
213
|
+
> 370 | var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
|
214
|
+
|
215
|
+
371 |
|
216
|
+
|
217
|
+
372 | if (process.env.NODE_ENV !== 'production') {
|
218
|
+
|
219
|
+
373 | if (debugID !== 0) {
|
220
|
+
|
221
|
+
View compiled
|
222
|
+
|
223
|
+
ReactCompositeComponentWrapper.mountComponent
|
224
|
+
|
225
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:257
|
226
|
+
|
227
|
+
254 | if (inst.unstable_handleError) {
|
228
|
+
|
229
|
+
255 | markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
230
|
+
|
231
|
+
256 | } else {
|
232
|
+
|
233
|
+
> 257 | markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
234
|
+
|
235
|
+
258 | }
|
236
|
+
|
237
|
+
259 |
|
238
|
+
|
239
|
+
260 | if (inst.componentDidMount) {
|
240
|
+
|
241
|
+
View compiled
|
242
|
+
|
243
|
+
Object.mountComponent
|
244
|
+
|
245
|
+
node_modules/react-dom/lib/ReactReconciler.js:45
|
246
|
+
|
247
|
+
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
248
|
+
|
249
|
+
43 | }
|
250
|
+
|
251
|
+
44 | }
|
252
|
+
|
253
|
+
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
254
|
+
|
255
|
+
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
256
|
+
|
257
|
+
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
258
|
+
|
259
|
+
48 | }
|
260
|
+
|
261
|
+
View compiled
|
262
|
+
|
263
|
+
ReactCompositeComponentWrapper.performInitialMount
|
264
|
+
|
265
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:370
|
266
|
+
|
267
|
+
367 | );
|
268
|
+
|
269
|
+
368 | this._renderedComponent = child;
|
270
|
+
|
271
|
+
369 |
|
272
|
+
|
273
|
+
> 370 | var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
|
274
|
+
|
275
|
+
371 |
|
276
|
+
|
277
|
+
372 | if (process.env.NODE_ENV !== 'production') {
|
278
|
+
|
279
|
+
373 | if (debugID !== 0) {
|
280
|
+
|
281
|
+
View compiled
|
282
|
+
|
283
|
+
ReactCompositeComponentWrapper.mountComponent
|
284
|
+
|
285
|
+
node_modules/react-dom/lib/ReactCompositeComponent.js:257
|
286
|
+
|
287
|
+
254 | if (inst.unstable_handleError) {
|
288
|
+
|
289
|
+
255 | markup = this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
290
|
+
|
291
|
+
256 | } else {
|
292
|
+
|
293
|
+
> 257 | markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
294
|
+
|
295
|
+
258 | }
|
296
|
+
|
297
|
+
259 |
|
298
|
+
|
299
|
+
260 | if (inst.componentDidMount) {
|
300
|
+
|
301
|
+
View compiled
|
302
|
+
|
303
|
+
Object.mountComponent
|
304
|
+
|
305
|
+
node_modules/react-dom/lib/ReactReconciler.js:45
|
306
|
+
|
307
|
+
42 | ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
|
308
|
+
|
309
|
+
43 | }
|
310
|
+
|
311
|
+
44 | }
|
312
|
+
|
313
|
+
> 45 | var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
314
|
+
|
315
|
+
46 | if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
|
316
|
+
|
317
|
+
47 | transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
318
|
+
|
319
|
+
48 | }
|
320
|
+
|
321
|
+
View compiled
|
322
|
+
|
323
|
+
ReactDOMComponent.mountChildren
|
324
|
+
|
325
|
+
node_modules/react-dom/lib/ReactMultiChild.js:236
|
326
|
+
|
327
|
+
233 | if (process.env.NODE_ENV !== 'production') {
|
328
|
+
|
329
|
+
234 | selfDebugID = getDebugID(this);
|
330
|
+
|
331
|
+
235 | }
|
332
|
+
|
333
|
+
> 236 | var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);
|
334
|
+
|
335
|
+
237 | child._mountIndex = index++;
|
336
|
+
|
337
|
+
238 | mountImages.push(mountImage);
|
338
|
+
|
339
|
+
239 | }
|
340
|
+
|
341
|
+
View compiled
|
342
|
+
|
343
|
+
ReactDOMComponent._createInitialChildren
|
344
|
+
|
345
|
+
node_modules/react-dom/lib/ReactDOMComponent.js:703
|
346
|
+
|
347
|
+
700 | DOMLazyTree.queueText(lazyTree, contentToUse);
|
348
|
+
|
349
|
+
701 | }
|
350
|
+
|
351
|
+
702 | } else if (childrenToUse != null) {
|
352
|
+
|
353
|
+
> 703 | var mountImages = this.mountChildren(childrenToUse, transaction, context);
|
354
|
+
|
355
|
+
704 | for (var i = 0; i < mountImages.length; i++) {
|
356
|
+
|
357
|
+
705 | DOMLazyTree.queueChild(lazyTree, mountImages[i]);
|
358
|
+
|
359
|
+
706 | }
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
76
364
|
|
77
365
|
```
|
78
366
|
|
79
|
-
|
367
|
+
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
368
|
+
|
84
|
-
|
85
|
-
デコレーターを導入する設定を検討中。
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
エラー履歴②
|
90
|
-
|
91
|
-
---
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
ブログサンプルを用いて、作業を進めて見ました。
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
ブログにあったサンプルは、reduxも使用しているので、reduxとreact-reduxをnode-moduleに追加しました。
|
100
|
-
|
101
|
-
|
369
|
+
redux騒動でバージョンが変わったせいでしょうか。たくさんエラーです。
|
102
|
-
|
103
|
-
import文のfrom react/redux はreact-reduxだと思って修正しましたが、致命的にたくさんのエラーを吐きギブアップ状態です。。エラーのうちの1例としては、怒られてなかったindex.jsの ```jsx
|
104
|
-
|
105
|
-
ReactDOM.render(<App />, document.getElementById('root'))
|
106
|
-
|
107
|
-
```まで怒られる始末です。
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
●reduxを消し、解決します。
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
目下エラー
|
120
|
-
|
121
|
-
---
|
122
|
-
|
123
|
-
```jsx
|
124
|
-
|
125
|
-
./src/components/GuestOnly.jsx
|
126
|
-
|
127
|
-
Line 5: React.PropTypes is deprecated since React 15.5.0, use the npm module prop-types instead react/no-deprecated
|
128
|
-
|
129
|
-
```
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
UserOnlyもこの症状。
|
134
370
|
|
135
371
|
|
136
372
|
|
5
新たなエラー
test
CHANGED
File without changes
|
test
CHANGED
@@ -120,15 +120,17 @@
|
|
120
120
|
|
121
121
|
---
|
122
122
|
|
123
|
+
```jsx
|
123
124
|
|
125
|
+
./src/components/GuestOnly.jsx
|
124
126
|
|
125
|
-
|
127
|
+
Line 5: React.PropTypes is deprecated since React 15.5.0, use the npm module prop-types instead react/no-deprecated
|
128
|
+
|
129
|
+
```
|
126
130
|
|
127
131
|
|
128
132
|
|
129
|
-
|
133
|
+
UserOnlyもこの症状。
|
130
|
-
|
131
|
-
|
132
134
|
|
133
135
|
|
134
136
|
|
4
次の課題。redux削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
javascriptとreact、material-uiを用いて、アプリ作成しています。
|
2
|
+
|
3
|
+
---
|
2
4
|
|
3
5
|
- 搭載したい機能リスト
|
4
6
|
|
@@ -30,11 +32,21 @@
|
|
30
32
|
|
31
33
|
|
32
34
|
|
35
|
+
テストサーバーはreactのランチャー
|
33
36
|
|
34
37
|
|
35
38
|
|
36
39
|
|
40
|
+
|
41
|
+
エラー履歴①
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
|
46
|
+
|
37
47
|
[このブログ](https://qiita.com/suin/items/b7275ff3eb3486380c7e)の内容を試しましたが、そもそもjs上だけで動くものを作りたいのに加えて、jsxはreactのランチャーから行くと、たくさんのエラーを吐きました。
|
48
|
+
|
49
|
+
|
38
50
|
|
39
51
|
|
40
52
|
|
@@ -64,21 +76,19 @@
|
|
64
76
|
|
65
77
|
```
|
66
78
|
|
67
|
-
|
68
|
-
|
69
|
-
|
79
|
+
jsxの勉強不足で全くなんのエラーかわかりません。エラー文のコピペでは解決しませんでした。
|
70
|
-
|
71
|
-
エラー文のコピペでは解決しませんでした。__
|
72
|
-
|
73
|
-
@を削除して一旦解決。
|
74
80
|
|
75
81
|
|
76
82
|
|
77
|
-
|
83
|
+
●解決しました。
|
78
84
|
|
79
|
-
|
85
|
+
デコレーターを導入する設定を検討中。
|
80
86
|
|
81
87
|
|
88
|
+
|
89
|
+
エラー履歴②
|
90
|
+
|
91
|
+
---
|
82
92
|
|
83
93
|
|
84
94
|
|
@@ -98,7 +108,27 @@
|
|
98
108
|
|
99
109
|
|
100
110
|
|
111
|
+
|
112
|
+
|
101
|
-
|
113
|
+
●reduxを消し、解決します。
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
目下エラー
|
120
|
+
|
121
|
+
---
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
ブログサンプルより、UserOnly.jsxのconnectがreduxコンポーネントなので、JSかreactでの代用品作り。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
※初心者のため、これのコーディングに時間がかかります。
|
130
|
+
|
131
|
+
|
102
132
|
|
103
133
|
|
104
134
|
|
3
アドバイスをもとに修正。次の段階に行きましたが、エラー。
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,9 +66,11 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
-
jsxの勉強不足で全くなんのエラーかわかりません。
|
69
|
+
__jsxの勉強不足で全くなんのエラーかわかりません。
|
70
70
|
|
71
|
-
エラー文のコピペでは解決しませんでした。
|
71
|
+
エラー文のコピペでは解決しませんでした。__
|
72
|
+
|
73
|
+
@を削除して一旦解決。
|
72
74
|
|
73
75
|
|
74
76
|
|
@@ -78,4 +80,26 @@
|
|
78
80
|
|
79
81
|
|
80
82
|
|
83
|
+
|
84
|
+
|
85
|
+
ブログサンプルを用いて、作業を進めて見ました。
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
ブログにあったサンプルは、reduxも使用しているので、reduxとreact-reduxをnode-moduleに追加しました。
|
90
|
+
|
91
|
+
UserOnly.jsxなど、追加したファイルがエラーでした。
|
92
|
+
|
93
|
+
import文のfrom react/redux はreact-reduxだと思って修正しましたが、致命的にたくさんのエラーを吐きギブアップ状態です。。エラーのうちの1例としては、怒られてなかったindex.jsの ```jsx
|
94
|
+
|
95
|
+
ReactDOM.render(<App />, document.getElementById('root'))
|
96
|
+
|
97
|
+
```まで怒られる始末です。
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
糸口でも大歓迎なので、
|
102
|
+
|
103
|
+
|
104
|
+
|
81
105
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
2
jsx構文の導入を解決方針に。 jsx上でコンパイル不能のエラー。
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,6 +38,44 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
```ERRORCODE
|
42
|
+
|
43
|
+
Failed to compile
|
44
|
+
|
45
|
+
./src/components/UserOnly.jsx
|
46
|
+
|
47
|
+
Syntax error: Unexpected token (5:0)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
3 | import { connect } from "redux/react";
|
52
|
+
|
53
|
+
4 |
|
54
|
+
|
55
|
+
> 5 | @connect(state => ({
|
56
|
+
|
57
|
+
| ^
|
58
|
+
|
59
|
+
6 | session: state.session
|
60
|
+
|
61
|
+
7 | }))
|
62
|
+
|
63
|
+
8 | export default class UserOnly {
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
jsxの勉強不足で全くなんのエラーかわかりません。
|
70
|
+
|
71
|
+
エラー文のコピペでは解決しませんでした。
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
テストサーバーはReactランチャーのチュートリアルそのままを使用。
|
76
|
+
|
77
|
+
構文直す系のツールはよくわからないで使っています。
|
78
|
+
|
41
79
|
|
42
80
|
|
43
81
|
解決できるかたからのメッセージまたはGitへの直接の書き込み待ってます。
|
1
初心者マーク
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|