From d7f05adabbe94c976ff6a63a6f7a080d82218220 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vil=C3=A9m=20Duha?= <vilda.novak@gmail.com>
Date: Thu, 26 Mar 2020 12:25:54 +0100
Subject: [PATCH] BlenderKit: fix ratings

-rating was virtually possible even if not logged in, but in reality the user couldn't rate on server.
-ratings were sent far too often to server thanks to an extra call.
---
 blenderkit/ui.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 24db4bdfb..411e3acfc 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -990,6 +990,10 @@ def floor_raycast(context, mx, my):
 def is_rating_possible():
     ao = bpy.context.active_object
     ui = bpy.context.scene.blenderkitUI
+    preferences = bpy.context.preferences.addons['blenderkit'].preferences
+    #first test if user is logged in.
+    if preferences.api_key == '':
+        return False, False, None, None
     if bpy.context.scene.get('assets rated') is not None and ui.down_up == 'SEARCH':
         if bpy.context.mode in ('SCULPT', 'PAINT_TEXTURE'):
             b = utils.get_active_brush()
@@ -1096,9 +1100,7 @@ def interact_rating(r, mx, my, event):
                         bkit_ratings.rating_work_hours = wh
 
                 if event.type == 'LEFTMOUSE' and event.value == 'RELEASE':
-                    if bkit_ratings.rating_quality > 0.1 or bkit_ratings.rating_work_hours > 0.1:
-                        ratings.upload_rating(asset)
-                    ui.last_rating_time = time.time()
+                    ui.last_rating_time = time.time() # this prop seems obsolete now?
                 return True
             else:
                 ui.rating_button_on = True
-- 
GitLab