Commit 33149417 authored by Eugen Rochko's avatar Eugen Rochko

Improve progress tracking and design

parent 1d3b6990
@import url('https://fonts.googleapis.com/css?family=Quando|Judson|Montserrat:500|Roboto:400,500');
@import url('https://fonts.googleapis.com/css?family=Montserrat:500,600|Roboto:400,500');
$white: #fff !default; // color5
$lightest: #d9e1e8 !default; // color2
......@@ -73,6 +73,7 @@ body {
max-width: 600px;
margin: 0 auto;
padding: 30px 10px;
overflow-x: hidden;
}
a {
......@@ -226,6 +227,8 @@ h4 {
margin-bottom: 30px;
display: flex;
justify-content: space-between;
padding-bottom: 20px;
border-bottom: 1px solid lighten($darkest, 12%);
ul {
list-style: none;
......@@ -246,7 +249,7 @@ h4 {
line-height: 32px;
transition: color $transition-out;
font-family: 'Montserrat', sans-serif;
font-weight: 500;
font-weight: 600;
font-size: 14px;
img.link-logo {
......@@ -306,21 +309,19 @@ h4 {
}
.page-heading {
background: darken($darkest, 4%);
padding: 20px;
margin-bottom: 30px;
border-radius: 10px;
&.bottomless {
border-radius: 10px 10px 0 0;
}
h3 {
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 26px;
text-align: center;
color: $lightest;
small {
font-family: 'Roboto', sans-serif;
font-weight: 400;
margin-top: 20px;
display: block;
color: $lighter;
......
......@@ -5,6 +5,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
user = User.from_omniauth(request.env['omniauth.auth'], current_user)
if user.persisted?
reset_friend_finding_job!
sign_in_and_redirect(user)
else
redirect_to root_path
......@@ -17,4 +18,15 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def failure
redirect_to root_path
end
private
def reset_friend_finding_job!
if session[:job_id].present?
Sidekiq::Status.cancel(session[:job_id])
Sidekiq::Status.delete(session[:job_id])
end
session[:job_id] = nil
end
end
......@@ -53,4 +53,5 @@
\/
= succeed "." do
%a{:href => "https://twitter.com/MastodonProject"} @MastodonProject
%a{:href => "https://github.com/tootsuite/mastodon-bridge", :target => "_blank"} Source code
%br/
%a{:href => "https://source.joinmastodon.org/mastodon/bridge", :target => "_blank"} Source code
......@@ -9,13 +9,15 @@ class FindFriendsWorker
client = current_user.twitter_client
all_friend_ids = []
twitter_user = client.user
performed = 0
total twitter_user.friends_count
begin
client.friend_ids.each do |friend_id|
all_friend_ids << friend_id
at all_friend_ids.size
performed += 1
at performed
end
rescue Twitter::Error::TooManyRequests => error
sleep error.rate_limit.reset_in + 1
......@@ -27,7 +29,12 @@ class FindFriendsWorker
.reject { |user| user.mastodon.nil? }
unless current_user.mastodon.nil?
total (all_friend_ids * 2) + 1
users.each do |user|
performed += 1
at performed
begin
user.relative_account_id = Rails.cache.fetch("#{current_user.id}/#{current_user.mastodon.domain}/#{user.mastodon.uid}", expires_in: 1.week) do
account, _ = current_user.mastodon_client.perform_request(:get, '/api/v1/accounts/search', q: user.mastodon.uid, resolve: 'true', limit: 1)
......@@ -40,6 +47,8 @@ class FindFriendsWorker
end
set_relationships!(current_user, users)
performed += 1
at performed
end
Rails.cache.write("#{current_user.id}/friends", users.map { |u| [u.id, u.relative_account_id, u.following] })
......@@ -53,7 +62,7 @@ class FindFriendsWorker
param_str = account_ids.map { |id| "id[]=#{id}" }.join('&')
current_user.mastodon_client.perform_request(:get, "/api/v1/accounts/relationships?#{param_str}").each do |relationship|
account_map[relationship['id']].following = relationship['following']
account_map[relationship['id']].following = relationship['following'] || relationship['requested']
end
rescue Mastodon::Error, HTTP::Error, OpenSSL::SSL::SSLError
nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment