Skip to content
Draft
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
25 changes: 20 additions & 5 deletions src/renderer/src/view_models/XViewModel/jobs_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,26 @@ export async function runJobIndexConversations(
await vm.scrollUp(2000);
await vm.sleep(1000);

// If the conversations list is empty, there is no search text field
// Check if loading the DM page is causing one to ask for PIN
if (await vm.detectTweetsDMPinPage("https://x.com/i/chat")) {
vm.log(
"runJobIndexConversations",
"asking for DM PIN detected",
);
vm.pause()
vm.showBrowser = true;
vm.showAutomationNotice = false;

await vm.waitForURL("https://x.com/home");

vm.showBrowser = false;
vm.showAutomationNotice = true;
}

// If the conversations list is empty, there is no search bar
try {
// Wait for the search text field to appear with a 30 second timeout
await vm.waitForSelector(
'section input[type="text"]',
'[data-testid="dm-inbox-panel"] [data-testid="dm-search-bar"]',
"https://x.com/i/chat",
30000,
);
Expand All @@ -233,10 +248,10 @@ export async function runJobIndexConversations(
break;
}

// Wait for conversations to appear
// Wait for at least some conversations to appear
try {
await vm.waitForSelector(
'section div div[role="tablist"] div[data-testid="cellInnerDiv"]',
'[data-testid="dm-inbox-panel"] ul li a[id^="dm-conversation-option"]',
"https://x.com/i/chat",
);
break;
Expand Down
6 changes: 6 additions & 0 deletions src/renderer/src/view_models/XViewModel/view_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ export class XViewModel extends BaseViewModel {
return Helpers.syncProgress(this);
}

async detectTweetsDMPinPage(url: string): Promise<boolean> {
const newURL = new URL(this.webview?.getURL() || "");
const originalURL = new URL(url);
return newURL !== originalURL && newURL.pathname == "/i/chat/pin/recovery"
}

async indexTweetsHandleRateLimit(): Promise<boolean> {
return IndexJobs.indexTweetsHandleRateLimit(this);
}
Expand Down