Skip to content

Commit

Permalink
Merge pull request #18680 from brave/ksmith-remove-pending
Browse files Browse the repository at this point in the history
Remove pending contribution code
  • Loading branch information
zenparsing authored May 31, 2023
2 parents 47e079a + 48cec05 commit d2c0364
Show file tree
Hide file tree
Showing 75 changed files with 335 additions and 1,710 deletions.
10 changes: 0 additions & 10 deletions .storybook/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ let locale: Record<string, string> = {
openBalance: 'Opening Balance',
payment: 'Payment',
paymentNotMade: 'Payment not made.',
pendingContributions: 'Pending Contributions',
pendingContributionEmpty: 'No pending contributions…',
pendingContributionRemoveAll: 'Remove All',
pendingTypeac: 'Auto-Contribute',
pendingTyperecurring: 'Recurring contribution',
pendingTypetip: 'Contribution',
pendingUntil: 'Pending until',
pinnedSitesHeader: 'Pinned sites are now',
pinnedSitesMsg: 'Here\'s how monthly tips work:',
pinnedSitesOne: 'Monthly tips do not come out of your Auto-Contribute payment. They\'re separate.',
Expand All @@ -148,11 +141,8 @@ let locale: Record<string, string> = {
recurringDonations: 'Monthly Contributions',
relaunch: 'Relaunch',
remove: 'remove',
reservedAllLink: 'Show all pending contributions',
resetWallet: 'Reset Brave Rewards',
removeAdFromSaved: 'Remove From Saved',
reservedAmountText: 'You’ve designated {{reservedAmount}} BAT for creators who haven’t yet signed up to receive contributions. We’ll keep trying to contribute until they verify, or until 90 days have passed.',
reservedMoreLink: 'Learn more.',
clearExcludeList: 'Clear exclude list',
removeFromExcluded: 'Remove from excluded',
reviewSitesMsg: 'Your pinned sites have been moved to',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,6 @@ public String[] GetCurrentGrant(int position) {
}
}

public void GetPendingContributionsTotal() {
synchronized(lock) {
BraveRewardsNativeWorkerJni.get().getPendingContributionsTotal(
mNativeBraveRewardsNativeWorker);
}
}

public void GetRecurringDonations() {
synchronized(lock) {
BraveRewardsNativeWorkerJni.get().getRecurringDonations(
Expand Down Expand Up @@ -642,13 +635,6 @@ public void OnNotificationDeleted(String id) {
}
}

@CalledByNative
public void OnGetPendingContributionsTotal(double amount) {
for (BraveRewardsObserver observer : mObservers) {
observer.OnGetPendingContributionsTotal(amount);
}
}

@CalledByNative
public void OnGetAutoContributeProperties() {
for (BraveRewardsObserver observer : mObservers) {
Expand Down Expand Up @@ -751,13 +737,6 @@ public void onSendContribution(boolean result) {
}
}

@CalledByNative
public void OnPendingContributionSaved(int result) {
for (BraveRewardsObserver observer : mObservers) {
observer.OnPendingContributionSaved(result);
}
}

@CalledByNative
public void onUnblindedTokensReady() {
for (BraveRewardsObserver observer : mObservers) {
Expand Down Expand Up @@ -822,7 +801,6 @@ void donate(long nativeBraveRewardsNativeWorker, String publisher_key, double am
void deleteNotification(long nativeBraveRewardsNativeWorker, String notification_id);
void getGrant(long nativeBraveRewardsNativeWorker, String promotionId);
String[] getCurrentGrant(long nativeBraveRewardsNativeWorker, int position);
void getPendingContributionsTotal(long nativeBraveRewardsNativeWorker);
void getRecurringDonations(long nativeBraveRewardsNativeWorker);
boolean isCurrentPublisherInRecurrentDonations(
long nativeBraveRewardsNativeWorker, String publisher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public interface BraveRewardsObserver {
default public void OnGetLatestNotification(
String id, int type, long timestamp, String[] args){};
default public void OnNotificationDeleted(String id){};
default public void OnGetPendingContributionsTotal(double amount){};
default public void OnGetAutoContributeProperties(){};
default public void onGetAutoContributionAmount(double amount){};
default public void OnGetReconcileStamp(long timestamp){};
Expand All @@ -33,7 +32,6 @@ default public void onUnblindedTokensReady() {}
default public void onReconcileComplete(int resultCode, int rewardsType, double amount) {}
default public void OnRefreshPublisher(int status, String publisherKey){};
default public void onSendContribution(boolean result){};
default public void OnPendingContributionSaved(int result){};
default public void OnGetAdsAccountStatement(boolean success, double nextPaymentDate,
int adsReceivedThisMonth, double earningsThisMonth, double earningsLastMonth){};
default public void onPublisherBanner(String jsonBannerInfo){};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,6 @@ public void OnGetCurrentBalanceReport(double[] report) {
tvUSD.setText(textUSD);
}
}

mBraveRewardsNativeWorker.GetPendingContributionsTotal();
}

private void requestNotificationPermission() {
Expand Down
24 changes: 0 additions & 24 deletions browser/brave_rewards/android/brave_rewards_native_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,6 @@ void BraveRewardsNativeWorker::OnReconcileComplete(
static_cast<int>(result), static_cast<int>(type), amount);
}

void BraveRewardsNativeWorker::OnPendingContributionSaved(
brave_rewards::RewardsService* rewards_service,
const brave_rewards::mojom::Result result) {
JNIEnv* env = base::android::AttachCurrentThread();
Java_BraveRewardsNativeWorker_OnPendingContributionSaved(
env, weak_java_brave_rewards_native_worker_.get(env),
static_cast<int>(result));
}

base::android::ScopedJavaLocalRef<jstring>
BraveRewardsNativeWorker::GetPublisherURL(JNIEnv* env, uint64_t tabId) {
base::android::ScopedJavaLocalRef<jstring> res =
Expand Down Expand Up @@ -597,14 +588,6 @@ base::android::ScopedJavaLocalRef<jobjectArray>
return base::android::ToJavaArrayOfStrings(env, values);
}

void BraveRewardsNativeWorker::GetPendingContributionsTotal(JNIEnv* env) {
if (brave_rewards_service_) {
brave_rewards_service_->GetPendingContributionsTotal(base::BindOnce(
&BraveRewardsNativeWorker::OnGetPendingContributionsTotal,
weak_factory_.GetWeakPtr()));
}
}

void BraveRewardsNativeWorker::GetRecurringDonations(JNIEnv* env) {
if (brave_rewards_service_) {
brave_rewards_service_->GetRecurringTips(
Expand Down Expand Up @@ -719,13 +702,6 @@ void BraveRewardsNativeWorker::OnGetGetReconcileStamp(uint64_t timestamp) {
weak_java_brave_rewards_native_worker_.get(env), timestamp);
}

void BraveRewardsNativeWorker::OnGetPendingContributionsTotal(double amount) {
JNIEnv* env = base::android::AttachCurrentThread();

Java_BraveRewardsNativeWorker_OnGetPendingContributionsTotal(env,
weak_java_brave_rewards_native_worker_.get(env), amount);
}

void BraveRewardsNativeWorker::OnNotificationAdded(
brave_rewards::RewardsNotificationService* rewards_notification_service,
const brave_rewards::RewardsNotificationService::RewardsNotification&
Expand Down
8 changes: 0 additions & 8 deletions browser/brave_rewards/android/brave_rewards_native_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ class BraveRewardsNativeWorker
base::android::ScopedJavaLocalRef<jobjectArray> GetCurrentGrant(JNIEnv* env,
int position);

void GetPendingContributionsTotal(JNIEnv* env);

void GetRecurringDonations(JNIEnv* env);

bool IsCurrentPublisherInRecurrentDonations(
Expand Down Expand Up @@ -192,8 +190,6 @@ class BraveRewardsNativeWorker

void OnGetAutoContributionAmount(double auto_contribution_amount);

void OnGetPendingContributionsTotal(double amount);

void OnPanelPublisherInfo(brave_rewards::RewardsService* rewards_service,
const brave_rewards::mojom::Result result,
const brave_rewards::mojom::PublisherInfo* info,
Expand All @@ -219,10 +215,6 @@ class BraveRewardsNativeWorker
const brave_rewards::mojom::RewardsType type,
const brave_rewards::mojom::ContributionProcessor processor) override;

void OnPendingContributionSaved(
brave_rewards::RewardsService* rewards_service,
const brave_rewards::mojom::Result result) override;

void OnNotificationAdded(
brave_rewards::RewardsNotificationService* rewards_notification_service,
const brave_rewards::RewardsNotificationService::RewardsNotification&
Expand Down
33 changes: 0 additions & 33 deletions browser/brave_rewards/extension_rewards_service_observer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ void ExtensionRewardsServiceObserver::OnAdsEnabled(
event_router->BroadcastEvent(std::move(event));
}

void ExtensionRewardsServiceObserver::OnPendingContributionSaved(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result) {
auto* event_router = extensions::EventRouter::Get(profile_);
if (!event_router) {
return;
}

std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events::BRAVE_START,
extensions::api::brave_rewards::OnPendingContributionSaved::kEventName,
extensions::api::brave_rewards::OnPendingContributionSaved::Create(
static_cast<int>(result))));
event_router->BroadcastEvent(std::move(event));
}

void ExtensionRewardsServiceObserver::OnPublisherListNormalized(
RewardsService* rewards_service,
std::vector<brave_rewards::mojom::PublisherInfoPtr> list) {
Expand Down Expand Up @@ -243,23 +227,6 @@ void ExtensionRewardsServiceObserver::OnRecurringTipRemoved(
event_router->BroadcastEvent(std::move(event));
}

void ExtensionRewardsServiceObserver::OnPendingContributionRemoved(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result) {
extensions::EventRouter* event_router =
extensions::EventRouter::Get(profile_);
if (!event_router) {
return;
}

std::unique_ptr<extensions::Event> event(new extensions::Event(
extensions::events::BRAVE_START,
extensions::api::brave_rewards::OnPendingContributionRemoved::kEventName,
extensions::api::brave_rewards::OnPendingContributionRemoved::Create(
static_cast<int>(result))));
event_router->BroadcastEvent(std::move(event));
}

void ExtensionRewardsServiceObserver::OnReconcileComplete(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result,
Expand Down
8 changes: 0 additions & 8 deletions browser/brave_rewards/extension_rewards_service_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ class ExtensionRewardsServiceObserver : public RewardsServiceObserver {
void OnRecurringTipRemoved(RewardsService* rewards_service,
bool success) override;

void OnPendingContributionRemoved(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result) override;

void OnReconcileComplete(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result,
Expand All @@ -80,10 +76,6 @@ class ExtensionRewardsServiceObserver : public RewardsServiceObserver {
const brave_rewards::mojom::Result result,
brave_rewards::mojom::PromotionPtr promotion) override;

void OnPendingContributionSaved(
RewardsService* rewards_service,
const brave_rewards::mojom::Result result) override;

void OnAdsEnabled(RewardsService* rewards_service, bool ads_enabled) override;

void OnCompleteReset(const bool success) override;
Expand Down
24 changes: 0 additions & 24 deletions browser/extensions/api/brave_rewards_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,30 +942,6 @@ void BraveRewardsAttestPromotionFunction::OnAttestPromotion(
Respond(WithArguments(static_cast<int>(result), std::move(data)));
}

BraveRewardsGetPendingContributionsTotalFunction::
~BraveRewardsGetPendingContributionsTotalFunction() = default;

ExtensionFunction::ResponseAction
BraveRewardsGetPendingContributionsTotalFunction::Run() {
Profile* profile = Profile::FromBrowserContext(browser_context());
RewardsService* rewards_service =
RewardsServiceFactory::GetForProfile(profile);

if (!rewards_service) {
return RespondNow(WithArguments(0.0));
}

rewards_service->GetPendingContributionsTotal(base::BindOnce(
&BraveRewardsGetPendingContributionsTotalFunction::OnGetPendingTotal,
this));
return RespondLater();
}

void BraveRewardsGetPendingContributionsTotalFunction::OnGetPendingTotal(
double amount) {
Respond(WithArguments(amount));
}

BraveRewardsSaveAdsSettingFunction::~BraveRewardsSaveAdsSettingFunction() =
default;

Expand Down
15 changes: 0 additions & 15 deletions browser/extensions/api/brave_rewards_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,21 +344,6 @@ class BraveRewardsAttestPromotionFunction : public ExtensionFunction {
brave_rewards::mojom::PromotionPtr promotion);
};

class BraveRewardsGetPendingContributionsTotalFunction
: public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION(
"braveRewards.getPendingContributionsTotal", UNKNOWN)

protected:
~BraveRewardsGetPendingContributionsTotalFunction() override;

ResponseAction Run() override;

private:
void OnGetPendingTotal(double amount);
};

class BraveRewardsSaveAdsSettingFunction : public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveRewards.saveAdsSetting", UNKNOWN)
Expand Down
4 changes: 0 additions & 4 deletions browser/ui/webui/brave_rewards/rewards_panel_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ static constexpr webui::LocalizedString kStrings[] = {
IDS_REWARDS_NOTIFICATION_MONTHLY_TIP_COMPLETED_TEXT},
{"notificationMonthlyTipCompletedTitle",
IDS_REWARDS_NOTIFICATION_MONTHLY_TIP_COMPLETED_TITLE},
{"notificationPublisherVerifiedText",
IDS_REWARDS_NOTIFICATION_PUBLISHER_VERIFIED_TEXT},
{"notificationPublisherVerifiedTitle",
IDS_REWARDS_NOTIFICATION_PUBLISHER_VERIFIED_TITLE},
{"notificationReconnect", IDS_REWARDS_NOTIFICATION_RECONNECT},
{"notificationWalletDisconnectedAction",
IDS_REWARDS_NOTIFICATION_WALLET_DISCONNECTED_ACTION},
Expand Down
Loading

0 comments on commit d2c0364

Please sign in to comment.