From 3a5c62cb704fff2650be8949c8ae99f6aa605545 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 27 Feb 2022 00:13:35 +0000 Subject: [PATCH 1/2] Revert "Merge branch 'revert-f59d977a' into 'develop'" This reverts merge request !1056 --- .eslintrc.js | Bin 5723 -> 5831 bytes .lintstagedrc.json | 1 + .../components/{badge.js => badge.tsx} | Bin 286 -> 291 bytes app/soapbox/utils/accounts.js | Bin 2088 -> 0 bytes app/soapbox/utils/accounts.ts | 82 +++++ babel.config.js | Bin 1383 -> 1410 bytes package.json | 7 +- tsconfig.json | 14 + webpack/configuration.js | Bin 766 -> 789 bytes webpack/rules/babel.js | Bin 528 -> 694 bytes webpack/rules/index.js | Bin 544 -> 494 bytes webpack/shared.js | Bin 3495 -> 3611 bytes yarn.lock | 285 +++++++++++++++++- 13 files changed, 382 insertions(+), 7 deletions(-) rename app/soapbox/components/{badge.js => badge.tsx} (89%) delete mode 100644 app/soapbox/utils/accounts.js create mode 100644 app/soapbox/utils/accounts.ts create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js index c12341232ef550d68f0bdcbbc66dbb75fded1b00..7ff1ba47871913384f005932c1691e52424380b3 100644 GIT binary patch delta 145 zcmcbub6j_Vu6;C@0uZRD7UyK>UQ$i&D~01<%$-T(jq diff --git a/app/soapbox/utils/accounts.js b/app/soapbox/utils/accounts.js deleted file mode 100644 index 3cf2c7cd51334e2e442cbbe448162f0257328ab2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2088 zcmcIl$!^;)5WV{=CO`p7fa(t3$0p3|5l*=e+zk~N?;;9veS_W0XIUMPK0|H3K^wJ zlJ5%5l`6TAQv&^Rdjk{TX{u^zU~&eV5rC;)-CuwvqOOY8X-x4EqbC-hk}p7ormiGN zdJDQnq+q{bn0x?5|bh144skM+6` zr0jyl^N$P5;OTtOIrtwZ2Nj5X{*=(6rW&=LKFXG~D`{S9tP+pCXuW#@aRzkXt{;Ao=$6%{<;TwTZC?QuB z6e{I~GwJR?*v?MtVsH9v@gu5XC-eMKvKZdpVC9>&E8B=#+J&SFUlJ-cDmYQ|1kDbA zr7p(-zkPzqWI`KJBb-}SrzeEQaMD#`9awzGD)gPdW_(cFlF?%|#IVFR4M zT@IJ09lfQsYD(1xc957bSZcON+P2t3N_`n?LbLPT;JZtS)d9ROt6q8s%i`ax())KC z%eigL_r&wT-A{j{X52iCOa2lC`1cSJX*>@Olh8MAZ4R#Yzn@Cm`dVg~3yB$xy_^0M z$a$fu5CckXu~f!Z+$U^D?Z^w<4QqcBh5m|_$OTb!0(): string => { + try { + const url = account.get('url'); + return new URL(url).host; + } catch { + return ''; + } +}; + +export const getDomain = (account: ImmutableMap): string => { + const domain = account.get('acct').split('@')[1]; + return domain ? domain : getDomainFromURL(account); +}; + +export const guessFqn = (account: ImmutableMap): string => { + const [user, domain] = account.get('acct').split('@'); + if (!domain) return [user, getDomainFromURL(account)].join('@'); + return account.get('acct'); +}; + +export const getBaseURL = (account: ImmutableMap): string => { + try { + const url = account.get('url'); + return new URL(url).origin; + } catch { + return ''; + } +}; + +// user@domain even for local users +export const acctFull = (account: ImmutableMap): string => ( + account.get('fqn') || guessFqn(account) +); + +export const getAcct = (account: ImmutableMap, displayFqn: boolean): string => ( + displayFqn === true ? acctFull(account) : account.get('acct') +); + +export const isStaff = (account: ImmutableMap = ImmutableMap()): boolean => ( + [isAdmin, isModerator].some(f => f(account) === true) +); + +export const isAdmin = (account: ImmutableMap): boolean => ( + account.getIn(['pleroma', 'is_admin']) === true +); + +export const isModerator = (account: ImmutableMap): boolean => ( + account.getIn(['pleroma', 'is_moderator']) === true +); + +export const getFollowDifference = (state: ImmutableMap, accountId: string, type: string): number => { + const items: any = state.getIn(['user_lists', type, accountId, 'items'], ImmutableOrderedSet()); + const counter: number = Number(state.getIn(['accounts_counters', accountId, `${type}_count`], 0)); + return Math.max(counter - items.size, 0); +}; + +export const isLocal = (account: ImmutableMap): boolean => { + const domain: string = account.get('acct').split('@')[1]; + return domain === undefined ? true : false; +}; + +export const isRemote = (account: ImmutableMap): boolean => !isLocal(account); + +export const isVerified = (account: ImmutableMap): boolean => { + const tags: any = account.getIn(['pleroma', 'tags'], ImmutableList()); + return tags.includes('verified'); +}; + +export const accountToMention = (account: ImmutableMap): ImmutableMap => { + return ImmutableMap({ + id: account.get('id'), + username: account.get('username'), + acct: account.get('acct'), + url: account.get('url'), + }); +}; diff --git a/babel.config.js b/babel.config.js index 1e167ead62d9d7978a94bd7d0eaa0096013f56f1..b9f7954d16bec2bfc98baea11afc821ba23b6644 100644 GIT binary patch delta 28 jcmaFP)xjjA;NIa0G(@ delta 61 zcmaFIyntmx2cx0BzJgC;aY;_4jzU3EesXGYu|jc4Vo7GQLRw}{YOz9Tab{jRn5~eL NpO}(bG`XEI9RQ}o7CZm| diff --git a/webpack/shared.js b/webpack/shared.js index 428b105487b6fc794e0d7e6a94ef2ee063410f43..d77475ba7f46974b9c9794b6894df1c2b79db341 100644 GIT binary patch delta 84 zcmZ23JzHkNCSJGvqU?}j=Zw_k?9`&kjEs`}X+RO(l49LtsF)n1qd Date: Mon, 28 Feb 2022 14:13:40 -0600 Subject: [PATCH 2/2] Typescript, Compose: use forEach --- app/soapbox/actions/compose.js | Bin 19701 -> 19690 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/app/soapbox/actions/compose.js b/app/soapbox/actions/compose.js index 3361188b662c9687082655115a7512b6eaac66c3..4b600c3d1d814e8dc7979030a46e2565c1626323 100644 GIT binary patch delta 70 zcmex5lkwF|#tpADlpTwT5-au6it=+c(lT>Wi#7Gq@{3#(lQT3l(sUFuH5F{_CQEA? avlXS5losV}4%R%)I(eFb-excT)v^G$%{p1dT5|FML*dQ#`m1FDn%W;P