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

ArConnect 1.5.0 - Notifications #248

Merged
merged 34 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
34877c9
feat: basic notification background worker completed
nicholaswma Feb 16, 2024
7c1665b
feat: ar notifications enabled, settings wip
nicholaswma Mar 1, 2024
466ddca
feat: v1 notifications completed
nicholaswma Mar 2, 2024
6e56a92
feat: notifications ui
elehma4 Mar 5, 2024
fbf75a3
feat: added ao token transactions to notifications
nicholaswma Mar 5, 2024
0050bf1
Merge branch 'arc-267/polling' into ARC-275-ar-connect-notifications-ui
elehma4 Mar 5, 2024
029ad4d
feat: fetch notification data
elehma4 Mar 6, 2024
c883db4
fix: added all ao and ao parser for notifications
nicholaswma Mar 6, 2024
ff4ea89
refactor: notifications ui and dependencies
elehma4 Mar 6, 2024
058df49
fix: updated ao messages for d/c added in warp support
nicholaswma Mar 6, 2024
8fbe839
style: add notification indicator and loading screen
elehma4 Mar 6, 2024
6eee65b
Merge branch 'arc-267/polling' into ARC-275-ar-connect-notifications-ui
elehma4 Mar 6, 2024
9fd742a
refactor: data sorting
elehma4 Mar 6, 2024
961311c
feat: add ao message screen to notifications
elehma4 Mar 6, 2024
38e5d04
feat: added customization settings for notifications
nicholaswma Mar 6, 2024
b955392
Merge branch 'arc-267/polling' into ARC-275-ar-connect-notifications-ui
elehma4 Mar 7, 2024
1005c0c
ci: update notifications ui
elehma4 Mar 7, 2024
9bb7c29
ci: update notification setting copy
elehma4 Mar 7, 2024
bfefcab
ci: fixsent tx > ao token recipient
elehma4 Mar 7, 2024
824e86d
ci: handle pending transactions
elehma4 Mar 7, 2024
68ea805
refactor: notifications > ao message screen
elehma4 Mar 7, 2024
7fa220d
fix: updated custom settings and notif return values
nicholaswma Mar 7, 2024
9210746
style: update icons
elehma4 Mar 7, 2024
99d1492
Merge branch 'arc-267/polling' into ARC-275-ar-connect-notifications-ui
elehma4 Mar 7, 2024
aa59f6c
fix: transactions to messages in ao
nicholaswma Mar 7, 2024
eea9e83
Merge branch 'arc-267/polling' into ARC-275-ar-connect-notifications-ui
elehma4 Mar 7, 2024
2fd94bf
ci: updated ui > ao messages
elehma4 Mar 7, 2024
a48149c
fix: updated bell icon notifier, fixed back button
nicholaswma Mar 8, 2024
e1e1f8c
ci: add empty notifications screen
elehma4 Mar 8, 2024
a5451a9
fix: handles undefined for notifs and moves new_notifs
nicholaswma Mar 8, 2024
38d977c
Merge pull request #246 from arconnectio/ARC-275-ar-connect-notificat…
nicholaswma Mar 8, 2024
2052020
Merge branch 'staging' into development
nicholaswma Mar 8, 2024
4576ec7
Merge pull request #247 from arconnectio/development
nicholaswma Mar 8, 2024
d401f21
chore: version bump for beta
nicholaswma Mar 8, 2024
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
8 changes: 8 additions & 0 deletions assets/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,14 @@
"message": "Wayfinder",
"description": "Wayfinder settings title"
},
"setting_notifications": {
"message": "Notifications",
"description": "Notifications settings title"
},
"setting_notifications_description": {
"message": "Toggle to receive alerts for new transactions in your wallet.",
"description": "Notifications settings description"
},
"setting_apps_description": {
"message": "View all connected apps & settings",
"description": "App settings description"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arconnect",
"displayName": "ArConnect",
"version": "1.3.0",
"version": "1.4.0",
"description": "__MSG_extensionDescription__",
"author": "th8ta",
"packageManager": "yarn@1.22.18",
Expand Down
4 changes: 4 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { handleGatewayUpdate } from "~gateways/cache";
import { onMessage } from "@arconnect/webext-bridge";
import { handleTabUpdate } from "~applications/tab";
import protocolHandler from "~gateways/ar_protocol";
import { notificationsHandler } from "~notifications/api";
import { appsChangeListener } from "~applications";
import handleFeeAlarm from "~api/modules/sign/fee";
import { ExtensionStorage } from "~utils/storage";
Expand All @@ -27,6 +28,9 @@ browser.tabs.onActivated.addListener(({ tabId }) => handleTabUpdate(tabId));
// handle fee alarm (send fees asyncronously)
browser.alarms.onAlarm.addListener(handleFeeAlarm);

// handle norifications
browser.alarms.onAlarm.addListener(notificationsHandler);

browser.alarms.onAlarm.addListener(trackBalance);

// handle alarm for updating gateways
Expand Down
93 changes: 93 additions & 0 deletions src/components/dashboard/NotificationSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { useStorage } from "@plasmohq/storage/hook";
import styled from "styled-components";
import PermissionCheckbox from "~components/auth/PermissionCheckbox";
import { ExtensionStorage } from "~utils/storage";
import { Input, Spacer, Text } from "@arconnect/components";
import browser from "webextension-polyfill";
import { Radio, RadioInner, RadioItem, RadioWrapper } from "./Setting";

export default function NotificationSettings() {
const [notificationSettings, setNotificationSettings] = useStorage(
{
key: "setting_notifications",
instance: ExtensionStorage
},
false
);
const [notificationCustomizeSettings, setNotificationCustomizeSettings] =
useStorage(
{
key: "setting_notifications_customize",
instance: ExtensionStorage
},
["default"]
);

const toggleNotificationSetting = () => {
setNotificationSettings(!notificationSettings);
};

const handleRadioChange = (setting) => {
setNotificationCustomizeSettings([setting]);
};

return (
<>
<Wrapper>
<PermissionCheckbox
onChange={toggleNotificationSetting}
checked={notificationSettings}
>
{browser.i18n.getMessage(
!!notificationSettings ? "enabled" : "disabled"
)}
<br />
<Text noMargin>
{browser.i18n.getMessage("setting_notifications_description")}
</Text>
</PermissionCheckbox>
<Spacer y={1.7} />
<RadioWrapper>
{/* AR AND AO TRANSFER NOTIFICATIONS */}
<RadioItem onClick={() => handleRadioChange("default")}>
<Radio>
{notificationCustomizeSettings &&
notificationCustomizeSettings.includes("default") && (
<RadioInner />
)}
</Radio>
<Text noMargin>
Enable Arweave and ao Transaction Notifications
</Text>
</RadioItem>
{/* JUST AR TRANSFER NOTIFICATIONS */}
<RadioItem
onClick={() => handleRadioChange("arTransferNotifications")}
>
<Radio>
{notificationCustomizeSettings &&
notificationCustomizeSettings.includes(
"arTransferNotifications"
) && <RadioInner />}
</Radio>
<Text noMargin>Enable Arweave Transaction Notifications</Text>
</RadioItem>
{/* ALL NOTIFICATIONS */}
<RadioItem onClick={() => handleRadioChange("allTxns")}>
<Radio>
{notificationCustomizeSettings &&
notificationCustomizeSettings.includes("allTxns") && (
<RadioInner />
)}
</Radio>
<Text noMargin>Enable all Arweave and ao Notifications</Text>
</RadioItem>
</RadioWrapper>
</Wrapper>
</>
);
}

const Wrapper = styled.div`
position: relative;
`;
8 changes: 4 additions & 4 deletions src/components/dashboard/Setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ interface Props {
setting: SettingType;
}

const RadioWrapper = styled.div`
export const RadioWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 0.05rem;
`;

const Radio = styled(Squircle).attrs((props) => ({
export const Radio = styled(Squircle).attrs((props) => ({
outline: `rgba(${props.theme.theme}, .7)`
}))`
position: relative;
Expand All @@ -154,7 +154,7 @@ const Radio = styled(Squircle).attrs((props) => ({
height: 1rem;
`;

const RadioInner = styled(Squircle)`
export const RadioInner = styled(Squircle)`
position: absolute;
top: 50%;
left: 50%;
Expand All @@ -165,7 +165,7 @@ const RadioInner = styled(Squircle)`
transition: all 0.23s ease-in-out;
`;

const RadioItem = styled.div`
export const RadioItem = styled.div`
display: flex;
align-items: center;
gap: 0.7rem;
Expand Down
37 changes: 35 additions & 2 deletions src/components/popup/WalletHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ import browser from "webextension-polyfill";
import styled from "styled-components";
import copy from "copy-to-clipboard";
import { type Gateway } from "~gateways/gateway";
import { Settings01 } from "@untitled-ui/icons-react";
import { Bell03 } from "@untitled-ui/icons-react";
import { svgie } from "~utils/svgies";
import { useHistory } from "~utils/hash_router";

export default function WalletHeader() {
// current address
Expand Down Expand Up @@ -126,7 +127,18 @@ export default function WalletHeader() {
// ui theme
const theme = useTheme();

// scroll position
// router push
const [push] = useHistory();

// has notifications
const [newNotifications, setNewNotifications] = useStorage<boolean>(
{
key: "new_notifications",
instance: ExtensionStorage
},
false
);

const [scrollY, setScrollY] = useState(0);

useEffect(() => {
Expand Down Expand Up @@ -220,6 +232,16 @@ export default function WalletHeader() {
</Tooltip>
</AddressContainer>
<WalletActions>
<Tooltip content="Notifications" position="bottom">
<Action
as={Bell03}
onClick={() => {
setNewNotifications(false);
push("/notifications");
}}
/>
{newNotifications && <Notifier />}
</Tooltip>
<Tooltip content="Viewblock" position="bottom">
<Action
as={BoxIcon}
Expand Down Expand Up @@ -466,6 +488,17 @@ const ExpandArrow = styled(ChevronDownIcon)<{ open: boolean }>`
transform: ${(props) => (props.open ? "rotate(180deg)" : "rotate(0)")};
`;

const Notifier = styled.div`
position: absolute;
right: -0.7px;
top: 0;
width: 8px;
height: 8px;
border-radius: 100%;
background-color: ${(props) => props.theme.fail};
border: 1px solid rgb(${(props) => props.theme.background});
`;

const AppAction = styled.div`
position: relative;
display: flex;
Expand Down
Loading
Loading