@@ -47,7 +47,7 @@ var BebopComments = Vue.component("bebop-comments", {
47
47
48
48
<div class="avatar-block">
49
49
<div class="cqldb comment">
50
- <a target="_blank" :href="comment.requestHash | getCommentSQLRequestHref" v-bind:class="{ disabled: isCommentHashEmpty (comment) }">
50
+ <a target="_blank" :href="comment.requestHash | getCommentSQLRequestHref" v-bind:class="{ disabled: !isCommentHashReady (comment) }">
51
51
<svg style="transform: translateY(6px);" width="20px" height="20px" viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><path id="a" d="M0 0h45v45H0z"/></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><g mask="url(#b)"><path d="M22.44 2L5 12.08v20.07l17.4 10.1h.06a60.48 60.48 0 0 1-.84-10.59v-1a8.94 8.94 0 1 1 7.85-3.31l.71.45a38.42 38.42 0 0 0 9.72 4.4V12.06L22.44 2zm-8.71 14.19a7.94 7.94 0 0 1 .51-7.32s.06-.09.08 0a14.83 14.83 0 0 0 1.11 3.58c.233.375.497.73.79 1.06a10.49 10.49 0 0 0-2.49 2.68zm17.38-.27a10.49 10.49 0 0 0-2.52-2.55 8 8 0 0 0 .75-1 7.91 7.91 0 0 0 1.1-3.44v-.18c0-.12 0-.07.08 0a7.94 7.94 0 0 1 .59 7.17z" fill="#FFF" fill-rule="nonzero"/></g></g></svg>
52
52
CovenantSQL
53
53
</a>
@@ -186,6 +186,7 @@ var BebopComments = Vue.component("bebop-comments", {
186
186
load : function ( ) {
187
187
this . topic = { } ;
188
188
this . topicReady = false ;
189
+ this . requestHashReady = { } ;
189
190
this . comments = [ ] ;
190
191
this . commentCount = 0 ;
191
192
this . commentsReady = false ;
@@ -200,19 +201,31 @@ var BebopComments = Vue.component("bebop-comments", {
200
201
} ,
201
202
202
203
// if comment.requestHash is empty, disable the button
203
- isCommentHashEmpty : function ( comment ) {
204
- return comment . requestHash === ''
204
+ isCommentHashReady : function ( comment ) {
205
+ return this . requestHashReady [ comment . requestHash ] === true
205
206
} ,
206
207
getCommentSQLQueries : function ( ) {
207
208
// DEPRECATED find possible height by Chenxi 2019-04-24
208
- return
209
- // this.comments.forEach(comment => {
210
- // const timestamp = (new Date(comment.createdAt)).getTime()
211
- // const possibleHeight = this.computeTimeHeight(timestamp)
212
- // console.log('// -- current comment possible height:', possibleHeight)
213
- //
214
- // this.getTimeRelatedBlocks(possibleHeight)
215
- // })
209
+ // Add polling to get current requestHash's block by Chenxi 2019-04-25
210
+ // set requestHashReady when the block is not emtpy, then stop polling
211
+ this . comments . forEach ( comment => {
212
+ const hash = comment . requestHash
213
+ if ( hash ) {
214
+ let interval = setInterval ( ( ) => {
215
+ let url = window . SQL_HASH_API ( hash )
216
+ fetch ( url ) . then ( res => res . json ( ) )
217
+ . then ( d => {
218
+ if ( d && d . data ) {
219
+ clearInterval ( interval )
220
+ this . requestHashReady [ hash ] = true
221
+ console . log ( hash , this . requestHashReady [ hash ] )
222
+ }
223
+ } )
224
+ . catch ( e => { console . info ( "get hash's block" , e ) } )
225
+ } , 3000 )
226
+ }
227
+ // this.getTimeRelatedBlocks(possibleHeight)
228
+ } )
216
229
} ,
217
230
writeSQL : function ( block ) {
218
231
if ( ! _ . isEmpty ( block ) ) {
0 commit comments