Просмотр исходного кода

Merge pull request #14831 from overleaf/jdt-hist-free-label

allow labels on history for free user versions over 24 hrs

GitOrigin-RevId: 8a71f999ad0bb22a5dc8155f14a39a4b625624ba
Jimmy Domagala-Tang 2 лет назад
Родитель
Сommit
6929984e04

+ 2 - 1
services/web/frontend/js/features/history/components/change-list/all-history-list.tsx

@@ -140,7 +140,8 @@ function AllHistoryList() {
           const showDivider = Boolean(update.meta.first_in_day && index > 0)
           const faded =
             updatesInfo.freeHistoryLimitHit &&
-            index === visibleUpdates.length - 1
+            index === visibleUpdates.length - 1 &&
+            visibleUpdates.length > 1
           const selectable =
             !faded &&
             (selection.comparing ||

+ 6 - 4
services/web/frontend/js/features/history/context/history-context.tsx

@@ -132,15 +132,17 @@ function useHistory() {
 
         previousUpdate = update
 
+        // the free tier cutoff is 24 hours, so show one extra update
+        //  after which will become the fade teaser above the paywall
         if (
           !userHasFullFeature &&
           visibleUpdateCount === null &&
           update.meta.end_ts < timestamp24hoursAgo
         ) {
-          // Make sure that we show at least one entry (to allow labelling), and
-          // load one extra update that is displayed but faded out above the
-          // paywall
-          visibleUpdateCount = index + 1
+          // Make sure that we show at least one entry fully (to allow labelling), and one extra for fading
+          //  Since the index for the first free tier cutoff will be at 0 if all versions were updated the day before (all version in the past),
+          //  we need to +2 instead of +1. this gives us one which is selected and one which is faded
+          visibleUpdateCount = index > 0 ? index + 1 : 2
           freeHistoryLimitHit = true
         }
       }