diff --git a/functions/package-lock.json b/functions/package-lock.json index 179e1668..521391c6 100644 --- a/functions/package-lock.json +++ b/functions/package-lock.json @@ -31,7 +31,6 @@ "puppeteer-core": "^10.1.0", "sharp": "^0.32.6", "source-map-support": "^0.5.10", - "tiny-cookie": "^2.3.2", "url-parse": "^1.5.9", "uuid": "^3.4.0", "vue": "^2.6.11", @@ -14845,11 +14844,6 @@ "node": ">=0.6.0" } }, - "node_modules/tiny-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tiny-cookie/-/tiny-cookie-2.3.2.tgz", - "integrity": "sha512-qbymkVh+6+Gc/c9sqnvbG+dOHH6bschjphK3SHgIfT6h/t+63GBL37JXNoXEc6u/+BcwU6XmaWUuf19ouLVtPg==" - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -27878,11 +27872,6 @@ "setimmediate": "^1.0.4" } }, - "tiny-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tiny-cookie/-/tiny-cookie-2.3.2.tgz", - "integrity": "sha512-qbymkVh+6+Gc/c9sqnvbG+dOHH6bschjphK3SHgIfT6h/t+63GBL37JXNoXEc6u/+BcwU6XmaWUuf19ouLVtPg==" - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", diff --git a/functions/package.json b/functions/package.json index a529829a..906a4bf2 100644 --- a/functions/package.json +++ b/functions/package.json @@ -38,7 +38,6 @@ "puppeteer-core": "^10.1.0", "sharp": "^0.32.6", "source-map-support": "^0.5.10", - "tiny-cookie": "^2.3.2", "url-parse": "^1.5.9", "uuid": "^3.4.0", "vue": "^2.6.11", diff --git a/src/mixins/embed-button.js b/src/mixins/embed-button.js index 4dbd05f7..7b1fa545 100644 --- a/src/mixins/embed-button.js +++ b/src/mixins/embed-button.js @@ -3,13 +3,14 @@ import { LIKE_CO_HOSTNAME } from '@/constant'; import { getAvatarHaloTypeFromUser } from '~/util/user'; import { isAndroid, isFacebookBrowser } from '~/util/client'; +import { apiGetLikeButtonTotalCount } from '~/util/api/api'; + import mixin from './embed'; export default { mixins: [mixin], data() { return { - isUserFetched: false, isShowLikeButton: true, }; }, @@ -29,21 +30,6 @@ export default { return this.$route.query.preview === '1'; }, }, - head() { - const link = []; - if (this.isUserFetched && !this.isLoggedIn) { - if (this.hasCookieSupport) { - if (!(window.doNotTrack || navigator.doNotTrack)) { // do not prefetch if DNT - link.push({ rel: 'prefetch', href: this.signUpUrl }); - } - } else { - link.push({ rel: 'prefetch', href: this.popupURL }); - } - } - return { - link, - }; - }, async mounted() { try { // Notify app when button is mounted @@ -54,10 +40,18 @@ export default { } window.addEventListener('message', this.handleWindowMessage); if (this.isPreview) { return; } - this.hasCookieSupport = await this.getIsCookieSupport(); - await this.updateUserSignInStatus(); - if (this.onCheckCookieSupport) { this.onCheckCookieSupport(this.hasCookieSupport); } - this.isUserFetched = true; + + const { id, referrer, iscnId } = this.likeTarget; + try { + const { data: totalData } = await apiGetLikeButtonTotalCount(id, { + referrer, + iscnId, + }); + this.totalLike = totalData.total; + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + } }, beforeDestroy() { window.removeEventListener('message', this.handleWindowMessage); diff --git a/src/mixins/embed.js b/src/mixins/embed.js index 7072e222..085f530c 100644 --- a/src/mixins/embed.js +++ b/src/mixins/embed.js @@ -1,8 +1,3 @@ -import { - isCookieEnabled, - setCookie, -} from 'tiny-cookie'; - import { LIKE_CO_HOSTNAME, LIKER_LAND_URL_BASE, @@ -24,7 +19,6 @@ import { apiGetNFTMintInfo, } from '~/util/api/api'; -import { checkHasStorageAPIAccess, checkIsFirefoxStrictMode } from '~/util/client'; import { checkIsValidISCNId, checkIsValidNFTClassId } from '~/util/nft'; import { handleQueryStringInUrl } from '~/util/url'; import { maskedWallet } from '~/util/cosmos'; @@ -43,7 +37,6 @@ const debouncedOnClick = debounce((that) => { apiPostLikeButton(that.likeTarget.id, count, { referrer: that.likeTarget.referrer, iscnId: that.likeTarget.iscnId, - isCookieSupport: that.hasCookieSupport, ...that.apiMetadata, }); } @@ -229,9 +222,6 @@ export default { hasFollowedCreator: false, isLoadingFollowStatus: false, - hasCookieSupport: false, - hasStorageAPIAccess: false, - hasUpdateUserSignInStatus: false, isRedirecting: false, @@ -347,31 +337,6 @@ export default { }, }, methods: { - async getIsCookieSupport() { - let res = false; - try { - this.hasStorageAPIAccess = await checkHasStorageAPIAccess(); - // Cross-site Cookie randomly disappear in fx strict mode - const isFirefoxStrictMode = checkIsFirefoxStrictMode(); - res = process.client && - navigator.cookieEnabled && - this.hasStorageAPIAccess && - isCookieEnabled() && - !isFirefoxStrictMode; - } catch (err) { - // eslint-disable-next-line no-console - console.error(err); - return false; - } - try { - setCookie('likebutton_cookie', 1); - } catch (err) { - // eslint-disable-next-line no-console - console.error(err); - return false; - } - return res; - }, async updateUserSignInStatus() { const { id, referrer, iscnId } = this.likeTarget; try { @@ -379,7 +344,6 @@ export default { apiGetLikeButtonMyStatus(id, { referrer, iscnId, - isCookieSupport: this.hasCookieSupport, ...this.apiMetadata, }) .then(async({ data: myData }) => { @@ -387,7 +351,6 @@ export default { liker, isSubscribed, isTrialSubscriber, - serverCookieSupported, civicLikerVersion, isSelfWork, } = myData; @@ -396,12 +359,6 @@ export default { this.isSubscribed = isSubscribed; this.isTrialSubscriber = isTrialSubscriber; this.civicLikerVersion = civicLikerVersion; - if ( - this.hasCookieSupport && - serverCookieSupported !== undefined - ) { - this.hasCookieSupport = serverCookieSupported; - } if (this.isLoggedIn) { if (this.$sentry) { this.$sentry.setUser({ id: liker }); diff --git a/src/package-lock.json b/src/package-lock.json index 6ae7863b..aca92f30 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -23,7 +23,6 @@ "nuxt": "^2.18.1", "nuxt-svg-loader": "^1.0.1", "on-headers": "^1.0.2", - "tiny-cookie": "^2.3.2", "url-parse": "^1.4.4", "uuid": "^3.4.0", "vue-gtag": "^1.16.1", @@ -33343,11 +33342,6 @@ "node": ">=0.6.0" } }, - "node_modules/tiny-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tiny-cookie/-/tiny-cookie-2.3.2.tgz", - "integrity": "sha512-qbymkVh+6+Gc/c9sqnvbG+dOHH6bschjphK3SHgIfT6h/t+63GBL37JXNoXEc6u/+BcwU6XmaWUuf19ouLVtPg==" - }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -60351,11 +60345,6 @@ "setimmediate": "^1.0.4" } }, - "tiny-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tiny-cookie/-/tiny-cookie-2.3.2.tgz", - "integrity": "sha512-qbymkVh+6+Gc/c9sqnvbG+dOHH6bschjphK3SHgIfT6h/t+63GBL37JXNoXEc6u/+BcwU6XmaWUuf19ouLVtPg==" - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", diff --git a/src/package.json b/src/package.json index 590a1d75..13f5d0ae 100644 --- a/src/package.json +++ b/src/package.json @@ -37,7 +37,6 @@ "nuxt": "^2.18.1", "nuxt-svg-loader": "^1.0.1", "on-headers": "^1.0.2", - "tiny-cookie": "^2.3.2", "url-parse": "^1.4.4", "uuid": "^3.4.0", "vue-gtag": "^1.16.1", diff --git a/src/pages/in/embed/_id/button.vue b/src/pages/in/embed/_id/button.vue index e33ce172..e6740c7c 100644 --- a/src/pages/in/embed/_id/button.vue +++ b/src/pages/in/embed/_id/button.vue @@ -37,12 +37,6 @@