Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't display indexTweets and indexLikes failures unless they're needed #343

Merged
merged 4 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/renderer/src/view_models/AccountXViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ Hang on while I scroll down to your earliest tweets.`;
this.progress = await window.electron.X.indexTweetsFinished(this.account?.id);

// On success, set the failure state to false
await window.electron.X.setConfig(this.account?.id, FailureState.indexTweets_FailedToRetryAfterRateLimit, "fail");
await window.electron.X.setConfig(this.account?.id, FailureState.indexTweets_FailedToRetryAfterRateLimit, "false");
break;
}

Expand Down Expand Up @@ -1482,13 +1482,16 @@ Hang on while I scroll down to your earliest likes.`;
await this.waitForPause();
await window.electron.X.resetRateLimitInfo(this.account?.id);
await this.loadURLWithRateLimit("https://x.com/" + this.account?.xAccount?.username + "/likes");
await this.sleep(500);

// Check if likes list is empty
if (await this.doesSelectorExist('div[data-testid="emptyState"]')) {
this.log("runJobIndexLikes", "no likes found");
this.progress.isIndexLikesFinished = true;
this.progress.likesIndexed = 0;
await this.syncProgress();
} else {
this.log("runJobIndexLikes", "did not find empty state");
}

if (!this.progress.isIndexLikesFinished) {
Expand Down Expand Up @@ -1590,7 +1593,7 @@ Hang on while I scroll down to your earliest likes.`;
this.progress = await window.electron.X.indexLikesFinished(this.account?.id);

// On success, set the failure state to false
await window.electron.X.setConfig(this.account?.id, FailureState.indexLikes_FailedToRetryAfterRateLimit, "fail");
await window.electron.X.setConfig(this.account?.id, FailureState.indexLikes_FailedToRetryAfterRateLimit, "false");
break;
}

Expand Down
69 changes: 32 additions & 37 deletions src/renderer/src/views/x/XFinishedRunningJobsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from 'vue';
import {
AccountXViewModel,
State
State,
FailureState
} from '../../view_models/AccountXViewModel'
import { openURL } from '../../util';

Expand Down Expand Up @@ -50,6 +51,10 @@ const submitErrorReportClicked = async () => {
// Settings
const archivePath = ref('');

const showFailureBoth = ref(false);
const showFailureTweets = ref(false);
const showFailureLikes = ref(false);

const updateArchivePath = async () => {
const path = await window.electron.getAccountDataPath(props.model.account.id, '');
archivePath.value = path ? path : '';
Expand All @@ -60,6 +65,26 @@ const hideErrors = ref(false);
onMounted(async () => {
await props.model.reloadAccount();
await updateArchivePath();

// See if we need to show any of the failure alerts
if (props.failureStateIndexTweets_FailedToRetryAfterRateLimit && props.failureStateIndexLikes_FailedToRetryAfterRateLimit && props.model.account.xAccount?.saveMyData && props.model.account.xAccount?.archiveTweets && props.model.account.xAccount?.archiveLikes) {
showFailureBoth.value = true;
showFailureTweets.value = false;
showFailureLikes.value = false;
}
if (props.failureStateIndexTweets_FailedToRetryAfterRateLimit && (props.model.account.xAccount?.saveMyData && props.model.account.xAccount?.archiveTweets)) {
showFailureTweets.value = true;
showFailureLikes.value = false;
showFailureBoth.value = false;
} if (props.failureStateIndexLikes_FailedToRetryAfterRateLimit && (props.model.account.xAccount?.saveMyData && props.model.account.xAccount?.archiveLikes)) {
showFailureLikes.value = true;
showFailureTweets.value = false;
showFailureBoth.value = false;
}

// Reset failure states
await window.electron.X.setConfig(props.model.account?.id, FailureState.indexTweets_FailedToRetryAfterRateLimit, "false");
await window.electron.X.setConfig(props.model.account?.id, FailureState.indexLikes_FailedToRetryAfterRateLimit, "false");
});
</script>

Expand Down Expand Up @@ -174,48 +199,18 @@ onMounted(async () => {
</button>
</div>

<div v-if="(
failureStateIndexTweets_FailedToRetryAfterRateLimit &&
((model.account.xAccount?.saveMyData && model.account.xAccount?.archiveTweets) || (model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteTweets))) ||
(
failureStateIndexLikes_FailedToRetryAfterRateLimit &&
((model.account.xAccount?.saveMyData && model.account.xAccount?.archiveLikes) || (model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteLikes))
)" class="alert alert-danger mt-4" role="alert">
<p v-if="(
failureStateIndexTweets_FailedToRetryAfterRateLimit &&
(model.account.xAccount?.archiveTweets || model.account.xAccount?.deleteTweets)) &&
(
failureStateIndexLikes_FailedToRetryAfterRateLimit &&
(model.account.xAccount?.archiveLikes || model.account.xAccount?.deleteLikes)
)" class="fw-bold mb-0">
<div v-if="showFailureBoth || showFailureTweets || showFailureLikes" class="alert alert-danger mt-4"
role="alert">
<p v-if="showFailureBoth" class="fw-bold mb-0">
Cyd wasn't able to scroll through all of your tweets and likes this time.
</p>
<p v-if="(
failureStateIndexTweets_FailedToRetryAfterRateLimit &&
(
(model.account.xAccount?.saveMyData && model.account.xAccount?.archiveTweets) ||
(model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteTweets)
)
) && !(
failureStateIndexLikes_FailedToRetryAfterRateLimit &&
((model.account.xAccount?.saveMyData && model.account.xAccount?.archiveLikes) || (model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteLikes))
)" class="fw-bold mb-0">
<p v-if="showFailureTweets" class="fw-bold mb-0">
Cyd wasn't able to scroll through all of your tweets this time.
</p>
<p v-if="!(
failureStateIndexTweets_FailedToRetryAfterRateLimit &&
((model.account.xAccount?.saveMyData && model.account.xAccount?.archiveTweets) || (model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteTweets))
) && (
failureStateIndexLikes_FailedToRetryAfterRateLimit &&
((model.account.xAccount?.saveMyData && model.account.xAccount?.archiveLikes) || (model.account.xAccount?.deleteMyData && model.account.xAccount?.deleteLikes))
)" class="fw-bold mb-0">
<p v-if="showFailureLikes" class="fw-bold mb-0">
Cyd wasn't able to scroll through all of your likes this time.
</p>
<p v-if="model.account.xAccount?.deleteMyData && (model.account.xAccount?.deleteTweets || model.account.xAccount?.deleteLikes)"
class="alert-details mb-0">
Run Cyd again with the same settings to delete more.
</p>
<p v-else class="alert-details mb-0">
<p class="alert-details mb-0">
Run Cyd again with the same settings to try again from the beginning.
</p>
</div>
Expand Down
Loading