@@ -25,6 +25,7 @@ import type { GitStatus } from '../../git/models/status';
25
25
import type { GitWorktree } from '../../git/models/worktree' ;
26
26
import { getOpenedWorktreesByBranch , groupWorktreesByBranch } from '../../git/models/worktree' ;
27
27
import type { Subscription } from '../../plus/gk/account/subscription' ;
28
+ import { isSubscriptionStatePaidOrTrial } from '../../plus/gk/account/subscription' ;
28
29
import type { SubscriptionChangeEvent } from '../../plus/gk/account/subscriptionService' ;
29
30
import { getLaunchpadSummary } from '../../plus/launchpad/utils' ;
30
31
import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol' ;
@@ -452,7 +453,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
452
453
}
453
454
454
455
private async getState ( subscription ?: Subscription ) : Promise < State > {
455
- const subResult = await this . getSubscription ( subscription ) ;
456
+ const subResult = await this . getSubscriptionState ( subscription ) ;
456
457
457
458
return {
458
459
...this . host . baseWebviewState ,
@@ -505,7 +506,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
505
506
branchesAndWorktrees ,
506
507
this . container ,
507
508
this . _overviewBranchFilter ,
508
- forceWip ? { forceActive : true } : undefined ,
509
+ {
510
+ forceActive : forceWip ? true : undefined ,
511
+ isPro : await this . isSubscriptionPro ( ) ,
512
+ } ,
509
513
) ;
510
514
this . _invalidateOverview = undefined ;
511
515
if ( overviewBranches == null ) return undefined ;
@@ -684,8 +688,28 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
684
688
return this . _hostedIntegrationConnected ;
685
689
}
686
690
691
+ private _subscription : Subscription | undefined ;
687
692
private async getSubscription ( subscription ?: Subscription ) {
688
- subscription ??= await this . container . subscription . getSubscription ( true ) ;
693
+ if ( subscription != null ) {
694
+ this . _subscription = subscription ;
695
+ } else if ( this . _subscription != null ) {
696
+ subscription = this . _subscription ;
697
+ } else {
698
+ this . _subscription = subscription = await this . container . subscription . getSubscription ( true ) ;
699
+ }
700
+
701
+ return this . _subscription ;
702
+ }
703
+
704
+ private async isSubscriptionPro ( ) {
705
+ const subscription = await this . getSubscription ( ) ;
706
+ if ( subscription == null ) return false ;
707
+
708
+ return isSubscriptionStatePaidOrTrial ( subscription . state ) ;
709
+ }
710
+
711
+ private async getSubscriptionState ( subscription ?: Subscription ) {
712
+ subscription = await this . getSubscription ( subscription ) ;
689
713
690
714
let avatar ;
691
715
if ( subscription . account ?. email ) {
@@ -756,7 +780,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
756
780
}
757
781
758
782
private async notifyDidChangeSubscription ( subscription ?: Subscription ) {
759
- const subResult = await this . getSubscription ( subscription ) ;
783
+ const subResult = await this . getSubscriptionState ( subscription ) ;
760
784
761
785
void this . host . notify ( DidChangeSubscription , {
762
786
subscription : subResult . subscription ,
@@ -903,7 +927,7 @@ async function getOverviewBranches(
903
927
branchesData : RepositoryBranchData ,
904
928
container : Container ,
905
929
filters : OverviewFilters ,
906
- options ?: { forceActive ?: boolean } ,
930
+ options ?: { forceActive ?: boolean ; isPro ?: boolean } ,
907
931
) : Promise < GetOverviewBranches | undefined > {
908
932
const { branches, worktreesByBranch } = branchesData ;
909
933
if ( branches . length === 0 ) return undefined ;
@@ -930,8 +954,15 @@ async function getOverviewBranches(
930
954
const timestamp = branch . date ?. getTime ( ) ;
931
955
if ( branch . current || wt ?. opened ) {
932
956
const forceOptions = options ?. forceActive ? { force : true } : undefined ;
933
- prPromises . set ( branch . id , branch . getAssociatedPullRequest ( { avatarSize : 16 } ) ) ;
934
- autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
957
+ if ( options ?. isPro !== false ) {
958
+ prPromises . set ( branch . id , branch . getAssociatedPullRequest ( { avatarSize : 16 } ) ) ;
959
+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
960
+ contributorPromises . set (
961
+ branch . id ,
962
+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
963
+ ) ;
964
+ }
965
+
935
966
if ( wt != null ) {
936
967
statusPromises . set ( branch . id , wt . getStatus ( forceOptions ) ) ;
937
968
} else {
@@ -940,7 +971,6 @@ async function getOverviewBranches(
940
971
}
941
972
statusPromises . set ( branch . id , repoStatusPromise ) ;
942
973
}
943
- contributorPromises . set ( branch . id , container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ) ;
944
974
945
975
overviewBranches . active . push ( {
946
976
id : branch . id ,
@@ -957,12 +987,18 @@ async function getOverviewBranches(
957
987
}
958
988
959
989
if ( timestamp != null && timestamp > recentThreshold ) {
960
- prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
961
- autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
990
+ if ( options ?. isPro !== false ) {
991
+ prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
992
+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
993
+ contributorPromises . set (
994
+ branch . id ,
995
+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
996
+ ) ;
997
+ }
998
+
962
999
if ( wt != null ) {
963
1000
statusPromises . set ( branch . id , wt . getStatus ( ) ) ;
964
1001
}
965
- contributorPromises . set ( branch . id , container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ) ;
966
1002
967
1003
overviewBranches . recent . push ( {
968
1004
id : branch . id ,
@@ -986,7 +1022,6 @@ async function getOverviewBranches(
986
1022
orderBy : 'date:asc' ,
987
1023
} ) ;
988
1024
for ( const branch of branches ) {
989
- autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
990
1025
if ( overviewBranches . stale . length > 9 ) break ;
991
1026
992
1027
if (
@@ -996,23 +1031,27 @@ async function getOverviewBranches(
996
1031
continue ;
997
1032
}
998
1033
1034
+ if ( options ?. isPro !== false ) {
1035
+ autolinkPromises . set ( branch . id , branch . getEnrichedAutolinks ( ) ) ;
1036
+ }
1037
+
999
1038
const timestamp = branch . date ?. getTime ( ) ;
1000
1039
if ( branch . upstream ?. missing || ( timestamp != null && timestamp < staleThreshold ) ) {
1001
1040
const wt = worktreesByBranch . get ( branch . id ) ;
1002
1041
const worktree : GetOverviewBranch [ 'worktree' ] = wt
1003
1042
? { name : wt . name , uri : wt . uri . toString ( ) }
1004
1043
: undefined ;
1005
1044
1006
- if ( ! branch . upstream ?. missing ) {
1045
+ if ( options ?. isPro !== false && ! branch . upstream ?. missing ) {
1007
1046
prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
1047
+ contributorPromises . set (
1048
+ branch . id ,
1049
+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
1050
+ ) ;
1008
1051
}
1009
1052
if ( wt != null ) {
1010
1053
statusPromises . set ( branch . id , wt . getStatus ( ) ) ;
1011
1054
}
1012
- contributorPromises . set (
1013
- branch . id ,
1014
- container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
1015
- ) ;
1016
1055
1017
1056
overviewBranches . stale . push ( {
1018
1057
id : branch . id ,
0 commit comments