Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit 226a3b9

Browse files
committed
fix: force connect when no address connected
1 parent d815804 commit 226a3b9

3 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/common/wallet.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ export async function connect(force = false) {
2929
}
3030

3131
if (force) {
32+
await metaMaskProvider.request({
33+
method: 'eth_requestAccounts',
34+
});
3235
await metaMaskProvider.request({
3336
method: 'wallet_requestPermissions',
3437
params: [

src/content-script/hooks/twitter.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class TwitterHook {
144144
grouping: true,
145145
});
146146

147-
const unidata = await this.main.getUnidata();
147+
const unidata = await this.main.getUnidata(true, settings.address);
148148
if (unidata) {
149149
try {
150150
const data = await unidata.notes.set(
@@ -257,7 +257,7 @@ class TwitterHook {
257257
// this.main.xlog('info', 'Settings is', settings);
258258
let newStatus = '';
259259
try {
260-
await this.main.getUnidata();
260+
await this.main.getUnidata(false, settings.address);
261261
} catch (e: any) {
262262
newStatus = e.message;
263263
this.main.xlog('warn', newStatus);
@@ -289,9 +289,10 @@ class TwitterHook {
289289
return link.split('/')[1];
290290
}
291291

292-
private mountSyncOldTweets() {
292+
private async mountSyncOldTweets() {
293293
// Only activate on Personal Timeline
294294
const username = this.getUsername();
295+
const settings = await getSettings();
295296

296297
this.main.xlog('info', 'Mounting sync old tweets button...');
297298

@@ -320,7 +321,7 @@ class TwitterHook {
320321
return this.noteCache.get(link);
321322
} else {
322323
// Check if it's already synced
323-
const unidata = await this.main.getUnidata();
324+
const unidata = await this.main.getUnidata(false, settings.address);
324325
const noteResp = await unidata?.notes.get({
325326
source: 'Crossbell Note',
326327
filter: {

src/content-script/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ class CrossSyncContentScript {
4545
}
4646
}
4747

48-
async getUnidata() {
48+
async getUnidata(force: boolean = false, addressInSettings?: string) {
4949
await this.lock.acquire('getUnidata', async () => {
5050
if (!this.unidata) {
5151
try {
52-
const provider = await w3mConnect(); // Metamask
52+
const provider = await w3mConnect(force); // Metamask
5353
if (provider) {
54-
this.address = (
55-
await provider.request({
56-
method: 'eth_accounts',
57-
})
58-
)?.[0];
54+
this.address =
55+
(
56+
await provider.request({
57+
method: 'eth_accounts',
58+
})
59+
)?.[0] || addressInSettings;
5960
if (!this.address) {
6061
throw new Error('No address found, MetaMask might be locked.');
6162
}

0 commit comments

Comments
 (0)