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

local browser notification #752

Merged
merged 21 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f3896fe
prework
RustemYuzlibaev Jul 11, 2022
8b19628
add notification modals
RustemYuzlibaev Jul 19, 2022
7e6a522
Merge branch 'develop' into feature/pw-722/local-browser-notification
RustemYuzlibaev Jul 19, 2022
97415ee
refactor & change watcher source
RustemYuzlibaev Jul 19, 2022
ba4e102
refactor
RustemYuzlibaev Jul 19, 2022
45aa16a
Update en.json
RustemYuzlibaev Jul 19, 2022
dcd9c8e
fix translation nesting
RustemYuzlibaev Jul 26, 2022
03ed772
translation fixes
RustemYuzlibaev Jul 26, 2022
767e36f
Merge branch 'develop' into feature/pw-722/local-browser-notification
RustemYuzlibaev Jul 28, 2022
b6dab8d
translations
RustemYuzlibaev Jul 28, 2022
5700d95
add bell icon
RustemYuzlibaev Jul 28, 2022
6662f2a
add svg icon
RustemYuzlibaev Jul 29, 2022
09a6185
Merge branch 'develop' into feature/pw-722/local-browser-notification
RustemYuzlibaev Jul 29, 2022
a612c31
add missing translations
RustemYuzlibaev Jul 29, 2022
3766f34
Merge branch 'feature/pw-722/local-browser-notification' of github.co…
RustemYuzlibaev Jul 29, 2022
6982161
fixes
RustemYuzlibaev Aug 4, 2022
8e7c182
upd translations
RustemYuzlibaev Aug 4, 2022
9f5b547
Merge branch 'develop' into feature/pw-722/local-browser-notification
RustemYuzlibaev Aug 4, 2022
ec74c4b
delete space between comma
RustemYuzlibaev Aug 4, 2022
d93da2d
Merge branch 'feature/pw-722/local-browser-notification' of github.co…
RustemYuzlibaev Aug 4, 2022
e9c61a1
Merge branch 'develop' into feature/pw-722/local-browser-notification
RustemYuzlibaev Aug 4, 2022
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^1.2.0",
"@soramitsu/soraneo-wallet-web": "^1.10.8",
"@soramitsu/soraneo-wallet-web": "^1.10.9",
"@walletconnect/web3-provider": "^1.6.6",
"core-js": "^3.6.4",
"direct-vuex": "^0.12.1",
Expand Down
43 changes: 43 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<referrals-confirm-invite-user :visible.sync="showConfirmInviteUser" />
<bridge-transfer-notification />
<mobile-popup :visible.sync="showMobilePopup" />
<browser-notifs-enable-dialog :visible.sync="showBrowserNotifPopup" @set-dark-page="setDarkPage" />
<browser-notifs-blocked-dialog :visible.sync="showBrowserNotifBlockedPopup" />
<notification-enabling-page v-if="showNotifsDarkPage" />
</s-design-system-provider>
</template>

Expand All @@ -61,6 +64,7 @@ import { getLocale } from '@/lang';
import type { ConnectToNodeOptions } from '@/types/nodes';
import type { SubNetwork } from '@/utils/ethers-util';
import type { FeatureFlags } from '@/store/settings/types';
import { WhitelistArrayItem } from '@sora-substrate/util/build/assets/types';

@Component({
components: {
Expand All @@ -70,16 +74,23 @@ import type { FeatureFlags } from '@/store/settings/types';
AppLogoButton: lazyComponent(Components.AppLogoButton),
ReferralsConfirmInviteUser: lazyComponent(Components.ReferralsConfirmInviteUser),
BridgeTransferNotification: lazyComponent(Components.BridgeTransferNotification),
BrowserNotifsEnableDialog: lazyComponent(Components.BrowserNotifsEnableDialog),
BrowserNotifsBlockedDialog: lazyComponent(Components.BrowserNotifsBlockedDialog),
NotificationEnablingPage: lazyComponent(Components.NotificationEnablingPage),
MobilePopup,
},
})
export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) {
menuVisibility = false;
showConfirmInviteUser = false;
showMobilePopup = false;
showNotifsDarkPage = false;

@state.wallet.settings.soraNetwork private soraNetwork!: Nullable<WALLET_CONSTS.SoraNetwork>;
@state.wallet.account.assetsToNotifyQueue assetsToNotifyQueue!: Array<WhitelistArrayItem>;
@state.referrals.storageReferrer storageReferrer!: string;
@state.settings.browserNotifPopupVisibility browserNotifPopup!: boolean;
@state.settings.browserNotifPopupBlockedVisibility browserNotifPopupBlocked!: boolean;
@state.settings.blockNumber blockNumber!: number;

@getter.wallet.transactions.firstReadyTx firstReadyTransaction!: Nullable<HistoryItem>;
Expand All @@ -94,6 +105,8 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
@mutation.settings.setNetworkChainGenesisHash private setNetworkChainGenesisHash!: (hash?: string) => void;
@mutation.settings.setFaucetUrl private setFaucetUrl!: (url: string) => void;
@mutation.settings.setFeatureFlags private setFeatureFlags!: (data: FeatureFlags) => void;
@mutation.settings.setBrowserNotifsPopupEnabled private setBrowserNotifsPopup!: (flag: boolean) => void;
@mutation.settings.setBrowserNotifsPopupBlocked private setBrowserNotifsPopupBlocked!: (flag: boolean) => void;
@mutation.settings.resetBlockNumberSubscription private resetBlockNumberSubscription!: VoidFunction;
@mutation.rewards.unsubscribeAccountMarketMakerInfo private unsubscribeMarketMakerInfo!: VoidFunction;
@mutation.referrals.unsubscribeFromInvitedUsers private unsubscribeFromInvitedUsers!: VoidFunction;
Expand All @@ -109,6 +122,16 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
@action.settings.setBlockNumber private setBlockNumber!: AsyncVoidFn;
@action.web3.setSmartContracts private setSmartContracts!: (data: Array<SubNetwork>) => Promise<void>;
@action.referrals.getReferrer private getReferrer!: AsyncVoidFn;
@action.wallet.account.notifyOnDeposit private notifyOnDeposit!: (info: {
asset: WhitelistArrayItem;
message: string;
}) => AsyncVoidFn;

@Watch('assetsToNotifyQueue')
private handleNotifyOnDeposit(whitelistAssetArray: WhitelistArrayItem[]): void {
if (!whitelistAssetArray.length) return;
this.notifyOnDeposit({ asset: whitelistAssetArray[0], message: this.t('assetDeposit') });
}

@Watch('firstReadyTransaction', { deep: true })
private handleNotifyAboutTransaction(value: History, oldValue: History): void {
Expand Down Expand Up @@ -213,6 +236,22 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
return getExplorerLinks(this.soraNetwork)[0].value;
}

get showBrowserNotifPopup(): boolean {
return this.browserNotifPopup;
}

set showBrowserNotifPopup(value) {
this.setBrowserNotifsPopup(value);
}

get showBrowserNotifBlockedPopup(): boolean {
return this.browserNotifPopupBlocked;
}

set showBrowserNotifBlockedPopup(value) {
this.setBrowserNotifsPopupBlocked(value);
}

goTo(name: PageNames): void {
goTo(name);
this.closeMenu();
Expand All @@ -230,6 +269,10 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
this.menuVisibility = false;
}

setDarkPage(value: boolean) {
this.showNotifsDarkPage = value;
}

handleAppMenuClick(e: Event): void {
const target = e.target as any;
const sidebar = !!target.closest('.app-sidebar');
Expand Down
Binary file added src/assets/img/browser-notification/arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/img/browser-notification/bell.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/img/browser-notification/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<dialog-base class="browser-notification" :title="t('browserNotificationDialog.title')" :visible.sync="isVisible">
<div class="browser-notification-dialog">
<p class="browser-notification-dialog__info">
{{ t('browserNotificationDialog.notificationBlocked', { appName: app.name }) }}
</p>
<s-button
type="primary"
class="s-typography-button--large browser-notification-dialog__btn"
:loading="loading"
@click="agree"
>
{{ t('browserNotificationDialog.agree') }}
</s-button>
</div>
</dialog-base>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';

import { mixins, components } from '@soramitsu/soraneo-wallet-web';
import { app } from '../../../consts';

import TranslationMixin from '@/components/mixins/TranslationMixin';

@Component({
components: {
DialogBase: components.DialogBase,
},
})
export default class BrowserNotifsBlockedDialog extends Mixins(
TranslationMixin,
mixins.DialogMixin,
mixins.LoadingMixin
) {
app = app;

agree(): void {
this.closeDialog();
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<dialog-base class="browser-notification" :title="t('browserNotificationDialog.title')" :visible.sync="isVisible">
<div class="browser-notification-dialog">
<img src="@/assets/img/browser-notification/chrome.png?inline" class="browser-notification-dialog__example" />
<p class="browser-notification-dialog__info">
{{ t('browserNotificationDialog.info') }}
</p>
<s-button
type="primary"
class="s-typography-button--large browser-notification-dialog__btn"
:loading="loading"
@click="handleConfirm"
>
{{ t('browserNotificationDialog.button') }}
</s-button>
</div>
</dialog-base>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';
import { components, mixins } from '@soramitsu/soraneo-wallet-web';

import TranslationMixin from '@/components/mixins/TranslationMixin';
import { mutation } from '@/store/decorators';

@Component({
components: {
DialogBase: components.DialogBase,
},
})
export default class BrowserNotifsEnableDialog extends Mixins(
TranslationMixin,
mixins.LoadingMixin,
mixins.DialogMixin
) {
@mutation.settings.setBrowserNotifsAgreement setBrowserNotifsAgreement!: (value: NotificationPermission) => void;
async handleConfirm(): Promise<void> {
this.closeDialog();
this.$emit('set-dark-page', true);
const permission = await Notification.requestPermission();
this.setBrowserNotifsAgreement(permission);
this.$emit('set-dark-page', false);
}
}
</script>

<style lang="scss">
.browser-notification {
.el-dialog__title {
margin: auto;
padding-left: var(--s-size-mini);
}

.el-dialog {
margin-top: 22vh !important;
}
}
.browser-notification-dialog {
display: flex;
flex-direction: column;

&__info {
text-align: center;
margin: $basic-spacing $basic-spacing * 2;
font-size: 15px;
font-weight: 300;
}

&__btn {
margin-bottom: $basic-spacing;
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<div class="notification-enabling-pointer">
<div class="notification-enabling-pointer__instructions">
<div class="notification-enabling-pointer__text">{{ t('browserNotificationDialog.pointer') }}</div>
</div>
</div>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';

import TranslationMixin from '@/components/mixins/TranslationMixin';

@Component
export default class NotificationEnablingPage extends Mixins(TranslationMixin) {}
</script>

<style lang="scss">
.notification-enabling-pointer {
display: flex;
justify-content: center;
align-items: center;
flex-direction: row;
position: absolute;

top: 0;
left: 0;
z-index: 90;
width: 100%;
height: 100%;
background-color: #000;
opacity: 0.8;
z-index: 300;

&__instructions {
display: flex;
position: relative;
}

&__text {
position: relative;
color: #fff;
font-size: 19px;
}

&__text::before {
content: '';
background: url('~@/assets/img/browser-notification/arrow.png') no-repeat;
width: 100%;
height: 300px;
position: absolute;
top: -275px;
left: -275px;
}
}
</style>
Loading