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

Fix notification links #1092

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -23,7 +23,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.17.17",
"@soramitsu/soraneo-wallet-web": "1.17.18",
"@walletconnect/web3-provider": "^1.8.0",
"base-64": "^1.0.0",
"core-js": "^3.26.0",
Expand Down
11 changes: 6 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
</template>

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

import axiosInstance, { updateBaseUrl } from '@/api';
import axiosInstance, { updateBaseUrl, getFullBaseUrl } from '@/api';
import AppFooter from '@/components/App/Footer/AppFooter.vue';
import AppHeader from '@/components/App/Header/AppHeader.vue';
import AppMenu from '@/components/App/Menu/AppMenu.vue';
Expand All @@ -56,11 +56,11 @@ import { PageNames, Components, Language } from '@/consts';
import { getLocale } from '@/lang';
import router, { goTo, lazyComponent } from '@/router';
import { action, getter, mutation, state } from '@/store/decorators';
import type { FeatureFlags } from '@/store/settings/types';
import type { EthBridgeSettings, SubNetworkApps } from '@/store/web3/types';
import type { ConnectToNodeOptions, Node } from '@/types/nodes';
import { preloadFontFace, updateDocumentTitle } from '@/utils';

import type { FeatureFlags } from './store/settings/types';
import type { EthBridgeSettings, SubNetworkApps } from './store/web3/types';
import type { ConnectToNodeOptions, Node } from './types/nodes';
import type { History, HistoryItem } from '@sora-substrate/util';
import type { WhitelistArrayItem } from '@sora-substrate/util/build/assets/types';
import type { EvmNetwork } from '@sora-substrate/util/build/bridgeProxy/evm/types';
Expand Down Expand Up @@ -195,6 +195,7 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
preloadFontFace('element-icons');

updateBaseUrl(router);
AlertsApiService.baseRoute = getFullBaseUrl(router);

await this.setLanguage(getLocale() as Language);

Expand Down
15 changes: 15 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ export const detectBaseUrl = (router?: VueRouter): string => {
return '';
};

export function getRouterMode(router?: VueRouter) {
return router?.mode === 'hash' ? '#/' : '';
}

/**
* Returns `detectBaseUrl` + router mode like:
*
* polkaswap.io/#/
*/
export function getFullBaseUrl(router?: VueRouter): string {
const routerMode = getRouterMode(router);
const baseUrl = detectBaseUrl(router);
return baseUrl + routerMode;
}

export const updateBaseUrl = (router: VueRouter): void => {
const baseUrl = detectBaseUrl(router);
axiosInstance.defaults.baseURL = baseUrl;
Expand Down
11 changes: 4 additions & 7 deletions src/views/ReferralProgram.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ import { components, mixins, api, WALLET_TYPES, WALLET_CONSTS } from '@soramitsu
import last from 'lodash/fp/last';
import { Component, Mixins, Watch } from 'vue-property-decorator';

import { detectBaseUrl } from '@/api';
import { getFullBaseUrl, getRouterMode } from '@/api';
import WalletConnectMixin from '@/components/mixins/WalletConnectMixin';
import { PageNames, ZeroStringValue } from '@/consts';
import router, { lazyView } from '@/router';
Expand Down Expand Up @@ -307,12 +307,8 @@ export default class ReferralProgram extends Mixins(
return cssClasses;
}

get routerMode(): string {
return router.mode === 'hash' ? '#/' : '';
}

get linkHrefBase(): string {
return `${detectBaseUrl(router)}${this.routerMode}referral/`;
return `${getFullBaseUrl(router)}referral/`;
}

get referralLink() {
Expand Down Expand Up @@ -404,7 +400,8 @@ export default class ReferralProgram extends Mixins(
}

getLinkLabel(address: string): string {
return `<span class="referral-link-address">Polkaswap.io/</span>${this.routerMode}referral/${address}`;
const routerMode = getRouterMode(router);
return `<span class="referral-link-address">Polkaswap.io/</span>${routerMode}referral/${address}`;
}

getInvitedUserReward(invitedUser: string): string {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2433,10 +2433,10 @@
vue-property-decorator "^9.1.2"
vuex "^3.6.2"

"@soramitsu/soraneo-wallet-web@1.17.17":
version "1.17.17"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.17.17.tgz#72d2040c8b369dbdb09f665646076e26a6a6c847"
integrity sha512-29c00pn6hAYJF7Nb0VKx6P6Q582H+SahCwXAs277K9FjmuBix7VuqMZQZ8WGaP7b31A6811AWeBbBaDcRS+xPQ==
"@soramitsu/soraneo-wallet-web@1.17.18":
version "1.17.18"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.17.18.tgz#c823223c3cc4650073d7afdc0ff7762ac7b6727e"
integrity sha512-FR9rhw38q1GsYPw0F7nQNJOTATynkHfFsSmnfG0JmGa1LdV34L+8ocIPObDGdYo0AAwDkkm+7wck66VZXn0cbQ==
dependencies:
"@polkadot/vue-identicon" "2.12.1"
"@sora-substrate/util" "1.17.21"
Expand Down