this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Apply auth for remote-instance API calls

+22
+17
src/utils/api.js
··· 4 4 import { 5 5 getAccount, 6 6 getAccountByAccessToken, 7 + getAccountByInstance, 7 8 getCurrentAccount, 8 9 saveAccount, 9 10 } from './store-utils'; ··· 244 245 masto: currentAccountApi.masto, 245 246 streaming: currentAccountApi.streaming, 246 247 client: currentAccountApi, 248 + authenticated: true, 249 + instance, 250 + }; 251 + } 252 + 253 + const instanceAccount = getAccountByInstance(instance); 254 + if (instanceAccount) { 255 + const accessToken = instanceAccount.accessToken; 256 + const client = 257 + accountApis[instance]?.[accessToken] || 258 + initClient({ instance, accessToken }); 259 + const { masto, streaming } = client; 260 + return { 261 + masto, 262 + streaming, 263 + client, 247 264 authenticated: true, 248 265 instance, 249 266 };
+5
src/utils/store-utils.js
··· 10 10 return accounts.find((a) => a.accessToken === accessToken); 11 11 } 12 12 13 + export function getAccountByInstance(instance) { 14 + const accounts = store.local.getJSON('accounts') || []; 15 + return accounts.find((a) => a.instanceURL === instance); 16 + } 17 + 13 18 export function getCurrentAccount() { 14 19 if (!window.__IGNORE_GET_ACCOUNT_ERROR__) { 15 20 // Track down getCurrentAccount() calls before account-based states are initialized