fix
authorClaromes <claromes@hey.com>
Sat, 13 May 2023 17:05:59 +0000 (14:05 -0300)
committerClaromes <claromes@hey.com>
Sat, 13 May 2023 17:05:59 +0000 (14:05 -0300)
README.md
app.py

index bd4361b7b1b7dd9586c4daca1a3079e970e15b5a..4743a96ae607d1394de9009ddb771a4be62934b3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -28,11 +28,14 @@ Streamlit will be served at http://localhost:8501
 
 - [ ] "web.archive.org took too long to respond."
 - [x] `only_deleted` checkbox selected for handles without deleted tweets
+    - [ ] Add message
 
 ## Roadmap
 
-- [ ] Feedbacks
 - [ ] Pagination
+    - [ ] Footer
+    - [ ] Disabled/ Empty
+- [ ] Feedbacks
 - [ ] Prevent duplicate URLs
 - [ ] Grid
-- [ ] About
\ No newline at end of file
+- [ ] About/Pagination
\ No newline at end of file
diff --git a/app.py b/app.py
index 29e7b965681d42a1d9d03a72f26355f9e7899f23..6939d49dccc1d0bd8bdd22cccf730bc34d214826 100644 (file)
--- a/app.py
+++ b/app.py
@@ -43,7 +43,7 @@ hide_streamlit_style = '''
     }
 </style>
 '''
-st.markdown(hide_streamlit_style, unsafe_allow_html=True)
+st.markdown(hide_streamlit_style, unsafe_allow_html=True)
 
 def embed(tweet):
     api = 'https://publish.twitter.com/oembed?url={}'.format(tweet)
@@ -67,6 +67,7 @@ def query_api(handle):
     else:
         return None
 
+@st.cache_data(show_spinner=False)
 def parse_links(links):
     parsed_links = []
     timestamp = []
@@ -106,24 +107,25 @@ if query or handle:
 
         only_deleted = st.checkbox('Only deleted tweets')
 
-        if links or stop:
+        if links:
             st.divider()
 
             return_none_count = 0
+            tweets_per_page = 2
 
             if 'current_index' not in st.session_state:
                 st.session_state.current_index = 0
 
             previous, _ , next = st.columns([3, 4, 3])
 
-            if previous.button('Previous', type='primary', use_container_width=True):
-                st.session_state.current_index -= 50
+            if previous.button('Previous', use_container_width=True) and st.session_state.current_index > 0:
+                st.session_state.current_index -= tweets_per_page
 
-            if next.button('Next', type='primary', use_container_width=True):
-                st.session_state.current_index += 50
+            if next.button('Next', use_container_width=True) and st.session_state.current_index < len(parsed_links):
+                st.session_state.current_index += tweets_per_page
 
             start_index = st.session_state.current_index
-            end_index = min(len(parsed_links), start_index + 50)
+            end_index = min(len(parsed_links), start_index + tweets_per_page)
 
             for i in range(start_index, end_index):
                 link = parsed_links[i]
@@ -151,7 +153,7 @@ if query or handle:
                         st.markdown('<iframe src="{}" height=700 width=700 scrolling="no"></iframe>'.format(link), unsafe_allow_html=True)
                         st.divider()
 
-                        progress.write('{}/{} URLs have been captured'.format(return_none_count, len(parsed_links)))
+                        progress.write('{}/{}-{} URLs have been captured'.format(return_none_count, start_index, end_index))
 
             if st.session_state.current_index >= len(parsed_links):
                 st.session_state.current_index = 0