From 595f5b7808766c7fd384c6e997ffaa59ee6d5d5f Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Wed, 20 Nov 2019 06:43:58 +0100 Subject: [PATCH 1/7] private api: remove subscription list --- src/app/data/models/twitch/ticket/model.js | 73 ----- .../ticket/product/emoticon/fragment.js | 18 -- .../ticket/product/features/fragment.js | 10 - .../models/twitch/ticket/product/fragment.js | 17 -- .../ticket/purchase-profile/fragment.js | 12 - .../data/models/twitch/ticket/serializer.js | 19 -- src/app/locales/de/components.yml | 20 -- src/app/locales/de/routes.yml | 5 - src/app/locales/en/components.yml | 20 -- src/app/locales/en/routes.yml | 5 - src/app/locales/fr/components.yml | 20 -- src/app/locales/fr/routes.yml | 5 - src/app/locales/zh-tw/components.yml | 20 -- src/app/locales/zh-tw/routes.yml | 5 - src/app/router.js | 1 - .../list/subscription-item/component.js | 56 ---- .../list/subscription-item/styles.less | 119 -------- .../list/subscription-item/template.hbs | 54 ---- src/app/ui/components/main-menu/component.js | 1 - src/app/ui/components/main-menu/template.hbs | 1 - src/app/ui/routes/user/subscriptions/route.js | 43 --- .../ui/routes/user/subscriptions/template.hbs | 14 - src/app/ui/styles/themes/dark.less | 4 - src/app/ui/styles/themes/light.less | 4 - src/config/twitch.json | 4 +- .../fixtures/data/models/twitch/ticket.json | 110 ------- src/test/tests/data/models/twitch/ticket.js | 285 ------------------ 27 files changed, 1 insertion(+), 944 deletions(-) delete mode 100644 src/app/data/models/twitch/ticket/model.js delete mode 100644 src/app/data/models/twitch/ticket/product/emoticon/fragment.js delete mode 100644 src/app/data/models/twitch/ticket/product/features/fragment.js delete mode 100644 src/app/data/models/twitch/ticket/product/fragment.js delete mode 100644 src/app/data/models/twitch/ticket/purchase-profile/fragment.js delete mode 100644 src/app/data/models/twitch/ticket/serializer.js delete mode 100644 src/app/ui/components/list/subscription-item/component.js delete mode 100644 src/app/ui/components/list/subscription-item/styles.less delete mode 100644 src/app/ui/components/list/subscription-item/template.hbs delete mode 100644 src/app/ui/routes/user/subscriptions/route.js delete mode 100644 src/app/ui/routes/user/subscriptions/template.hbs delete mode 100644 src/test/fixtures/data/models/twitch/ticket.json delete mode 100644 src/test/tests/data/models/twitch/ticket.js diff --git a/src/app/data/models/twitch/ticket/model.js b/src/app/data/models/twitch/ticket/model.js deleted file mode 100644 index 08e300ab2f..0000000000 --- a/src/app/data/models/twitch/ticket/model.js +++ /dev/null @@ -1,73 +0,0 @@ -import { alias } from "@ember/object/computed"; -import { get, computed } from "@ember/object"; -import attr from "ember-data/attr"; -import Model from "ember-data/model"; -import { belongsTo } from "ember-data/relationships"; -import { fragment } from "ember-data-model-fragments/attributes"; -import Moment from "moment"; - - -export default Model.extend({ - /** type {TwitchTicketProduct} */ - product: fragment( "twitch-ticket-product", { defaultValue: {} } ), - /** type {TwitchTicketPurchaseProfile} */ - purchase_profile: fragment( "twitch-ticket-purchase-profile", { defaultValue: {} } ), - - /** @type ComputedProperty> */ - partner_login: belongsTo( "twitch-user", { async: true } ), - - access_end: attr( "date" ), - access_start: attr( "date" ), - expired: attr( "boolean" ), - is_gift: attr( "boolean" ), - - /** @type ComputedProperty> */ - channel: alias( "partner_login.channel" ), - - - // load the chained PromiseProxy - async loadChannel() { - const user = this.partner_login; - await user.promise; - const channel = user.content.channel; - await channel.promise; - - return channel.content; - }, - - - hasEnded: computed(function() { - const access_end = get( this, "access_end" ); - - return access_end && new Date() > access_end; - }).volatile(), - - ends: computed(function() { - const access_end = get( this, "access_end" ); - - return new Moment().to( access_end ); - }).volatile(), - - - subbedFor: computed( "access_start", "purchase_profile.consecutive_months", function() { - const purchase_profile = this.purchase_profile; - if ( purchase_profile ) { - const months = purchase_profile.consecutive_months; - if ( Number.isInteger( months ) && months > 0 ) { - return months; - } - } - - const started = this.access_start; - if ( started ) { - const diff = new Moment().diff( new Moment( started ), "months", true ); - - return Math.ceil( diff ); - } - - return 1; - }) - -}).reopenClass({ - toString() { return "api/users/:user_name/tickets"; } -}); diff --git a/src/app/data/models/twitch/ticket/product/emoticon/fragment.js b/src/app/data/models/twitch/ticket/product/emoticon/fragment.js deleted file mode 100644 index 7f4fc902d7..0000000000 --- a/src/app/data/models/twitch/ticket/product/emoticon/fragment.js +++ /dev/null @@ -1,18 +0,0 @@ -import { computed } from "@ember/object"; -import { equal } from "@ember/object/computed"; -import attr from "ember-data/attr"; -import Fragment from "ember-data-model-fragments/fragment"; - - -export default Fragment.extend({ - regex: attr( "string" ), - regex_display: attr( "string" ), - state: attr( "string" ), - url: attr( "string" ), - - isActive: equal( "state", "active" ), - - title: computed( "regex", "regex_display", function() { - return this.regex_display || this.regex; - }) -}); diff --git a/src/app/data/models/twitch/ticket/product/features/fragment.js b/src/app/data/models/twitch/ticket/product/features/fragment.js deleted file mode 100644 index 3527666fc0..0000000000 --- a/src/app/data/models/twitch/ticket/product/features/fragment.js +++ /dev/null @@ -1,10 +0,0 @@ -import attr from "ember-data/attr"; -import Fragment from "ember-data-model-fragments/fragment"; -import { array } from "ember-data-model-fragments/attributes"; - - -export default Fragment.extend({ - base_emoticon_set_id: attr( "number" ), - emoticon_set_ids: array( "number" ), - tier: attr( "string" ) -}); diff --git a/src/app/data/models/twitch/ticket/product/fragment.js b/src/app/data/models/twitch/ticket/product/fragment.js deleted file mode 100644 index f78cc4f953..0000000000 --- a/src/app/data/models/twitch/ticket/product/fragment.js +++ /dev/null @@ -1,17 +0,0 @@ -import attr from "ember-data/attr"; -import Fragment from "ember-data-model-fragments/fragment"; -import { fragment, fragmentArray } from "ember-data-model-fragments/attributes"; - - -export default Fragment.extend({ - emoticons: fragmentArray( "twitch-ticket-product-emoticon" ), - features: fragment( "twitch-ticket-product-features", { defaultValue: {} } ), - interval_number: attr( "number" ), - name: attr( "string" ), - owner_name: attr( "string" ), - period: attr( "string" ), - price: attr( "string" ), - recurring: attr( "boolean" ), - short_name: attr( "string" ), - ticket_type: attr( "string" ) -}); diff --git a/src/app/data/models/twitch/ticket/purchase-profile/fragment.js b/src/app/data/models/twitch/ticket/purchase-profile/fragment.js deleted file mode 100644 index b063facf1c..0000000000 --- a/src/app/data/models/twitch/ticket/purchase-profile/fragment.js +++ /dev/null @@ -1,12 +0,0 @@ -import attr from "ember-data/attr"; -import Fragment from "ember-data-model-fragments/fragment"; - - -export default Fragment.extend({ - consecutive_months: attr( "number" ), - expired: attr( "boolean" ), - paid_on: attr( "date" ), - refundable: attr( "boolean" ), - renewal_date: attr( "date" ), - will_renew: attr( "boolean" ) -}); diff --git a/src/app/data/models/twitch/ticket/serializer.js b/src/app/data/models/twitch/ticket/serializer.js deleted file mode 100644 index 8f3fcb9de9..0000000000 --- a/src/app/data/models/twitch/ticket/serializer.js +++ /dev/null @@ -1,19 +0,0 @@ -import TwitchSerializer from "data/models/twitch/serializer"; - - -export default TwitchSerializer.extend({ - primaryKey: "id", - - modelNameFromPayloadKey() { - return "twitchTicket"; - }, - - normalize( modelClass, resourceHash ) { - // copy the partner_login info from the product fragment to the ticket - // EDMF doesn't support model relationships - const product = resourceHash.product; - resourceHash[ "partner_login" ] = product && product[ "partner_login" ]; - - return this._super( ...arguments ); - } -}); diff --git a/src/app/locales/de/components.yml b/src/app/locales/de/components.yml index 92d38fa6ce..b1772cb6de 100644 --- a/src/app/locales/de/components.yml +++ b/src/app/locales/de/components.yml @@ -26,7 +26,6 @@ main-menu: streams: Streams my: header: Meine - subscriptions: Abonnements live-streams: Live Streams hosted-streams: Hosts channels: Kanäle @@ -85,25 +84,6 @@ stream-item: subscribe-channel: title-new: "{{name}} jetzt abonnieren" title-renew: "Abonnement von {{name}} erneuern" -subscription-item: - cancel: Abonnement beenden - edit: Abonnement bearbeiten - access: - # new Moment(subscription.access_end).format(...) - title: "LLLL" - ended: "Ist beendet" - # time = new Moment().to(subscription.access_end) - renews: "Wird erneuert {{time}}" - # time = new Moment().to(subscription.access_end) - ends: "Wird enden {{time}}" - subscribed: Du hast den Kanal abonniert - support: Unterstützt den Kanal - # new Moment(subscription.created_at).format(...) - since: "[Seit] LLLL" - duration: - one: Abonniert seit einem Monat - other: Abonniert seit {{count}} Monaten - no-emoticons: Dieser Kanal hat (noch) keine Emoticons team-item: created-at: title: "Erstellt am" diff --git a/src/app/locales/de/routes.yml b/src/app/locales/de/routes.yml index 381212f6a7..c71ca1ee4f 100644 --- a/src/app/locales/de/routes.yml +++ b/src/app/locales/de/routes.yml @@ -135,11 +135,6 @@ user: first: Logge dich auf deinem Twitch.tv Account mit einem Zugangscode ein. second: "Stell sicher, dass er mit folgenen Berechtigungen übereinstimmt:" fail: Authentifizierung fehlgeschlagen. Bitte noch einmal versuchen. - subscriptions: - header: Abonnements - empty: - first: Du hast zur Zeit keine Abonnements. - second: Unterstütze Broadcaster durch das Abonnieren ihrer Kanäle. followedStreams: header: Gefolgte Streams empty: diff --git a/src/app/locales/en/components.yml b/src/app/locales/en/components.yml index a000a8834d..8ce843b41e 100644 --- a/src/app/locales/en/components.yml +++ b/src/app/locales/en/components.yml @@ -26,7 +26,6 @@ main-menu: streams: Streams my: header: My - subscriptions: Subscriptions live-streams: Live Streams hosted-streams: Hosted Streams channels: Channels @@ -85,25 +84,6 @@ stream-item: subscribe-channel: title-new: "Subscribe to {{name}} now" title-renew: "Renew subscription to {{name}}" -subscription-item: - cancel: Cancel subscription - edit: Edit subscription - access: - # new Moment(subscription.access_end).format(...) - title: "LLLL" - ended: "Has ended" - # time = new Moment().to(subscription.access_end) - renews: "Will be renewed {{time}}" - # time = new Moment().to(subscription.access_end) - ends: "Will end {{time}}" - subscribed: You are subscribed - support: Directly supports the channel - # new Moment(subscription.created_at).format(...) - since: "[Since] LLLL" - duration: - one: Subscribed for one month - other: Subscribed for {{count}} months - no-emoticons: This channel doesn't have any emoticons (yet) team-item: created-at: title: "Date created" diff --git a/src/app/locales/en/routes.yml b/src/app/locales/en/routes.yml index 91723bf355..684a67d251 100644 --- a/src/app/locales/en/routes.yml +++ b/src/app/locales/en/routes.yml @@ -135,11 +135,6 @@ user: first: Log in to your Twitch.tv account by using an access token. second: "Make sure that it matches the following permissions:" fail: Authentication failed. Please try again. - subscriptions: - header: Subscriptions - empty: - first: You don't have any channel subscriptions. - second: Directly support broadcasters by subscribing to their channel. followedStreams: header: Followed Streams empty: diff --git a/src/app/locales/fr/components.yml b/src/app/locales/fr/components.yml index e46375ad21..b10e6dc1fa 100644 --- a/src/app/locales/fr/components.yml +++ b/src/app/locales/fr/components.yml @@ -26,7 +26,6 @@ main-menu: streams: Streams my: header: Mes - subscriptions: Abonnements live-streams: Streams live hosted-streams: Streams Hébergés channels: Chaînes @@ -85,25 +84,6 @@ stream-item: subscribe-channel: title-new: "S'abonner à {{name}} maintenant" title-renew: "Renouveler l'abonnement à {{name}}" -subscription-item: - cancel: Annuler l'abonnement - edit: Modifier l'abonnement - access: - # new Moment(subscription.access_end).format(...) - title: "LLLL" - ended: "Est terminé" - # time = new Moment().to(subscription.access_end) - renews: "Sera renouvelé {{time}}" - # time = new Moment().to(subscription.access_end) - ends: "Se terminera {{time}}" - subscribed: Vou êtes abonné - support: Soutient directement le créateur - # new Moment(subscription.created_at).format(...) - since: "[Depuis] LLLL" - duration: - one: Abonné pour un mois - other: Abonné pour {{count}} mois - no-emoticons: Cette chaîne n'a pas (encore) d'émoticons team-item: created-at: title: "Date de création" diff --git a/src/app/locales/fr/routes.yml b/src/app/locales/fr/routes.yml index 4db882f5d5..075742f08e 100644 --- a/src/app/locales/fr/routes.yml +++ b/src/app/locales/fr/routes.yml @@ -135,11 +135,6 @@ user: first: Connectez-vous à votre compte Twitch.tv en utilisant un token d'accès. second: "Assurez-vous qu'il correspond aux permissions suivantes :" fail: L'authentification a échoué. Veuillez réessayer. - subscriptions: - header: Abonnements - empty: - first: Vous n'avez aucun abonnement. - second: Soutenez directement les streameurs en vous abonnant à leur chaîne. followedStreams: header: Stream suivis empty: diff --git a/src/app/locales/zh-tw/components.yml b/src/app/locales/zh-tw/components.yml index 58b75471ff..e2c1710ab0 100644 --- a/src/app/locales/zh-tw/components.yml +++ b/src/app/locales/zh-tw/components.yml @@ -26,7 +26,6 @@ main-menu: streams: 實況中 my: header: 我的 - subscriptions: 訂閱 live-streams: 實況 hosted-streams: 轉播 channels: 頻道 @@ -85,25 +84,6 @@ stream-item: subscribe-channel: title-new: "立即訂閱 {{name}}" title-renew: "更新訂閱 {{name}}" -subscription-item: - cancel: 不續訂 - edit: 編輯訂閱 - access: - # new Moment(subscription.access_end).format(...) - title: "LLLL" - ended: "已經結束訂閱" - # time = new Moment().to(subscription.access_end) - renews: "於 {{time}} 後更新" - # time = new Moment().to(subscription.access_end) - ends: "於 {{time}} 後停止訂閱" - subscribed: 已訂閱 - support: 直接贊助這個實況頻道 - # new Moment(subscription.created_at).format(...) - since: "[從] LLLL" - duration: - one: 已訂閱 1 個月 - other: 已訂閱 {{count}} 個月 - no-emoticons: 此頻道尚未有自訂表情符號 team-item: created-at: title: "建立日期" diff --git a/src/app/locales/zh-tw/routes.yml b/src/app/locales/zh-tw/routes.yml index 17150112e6..0147b385f2 100644 --- a/src/app/locales/zh-tw/routes.yml +++ b/src/app/locales/zh-tw/routes.yml @@ -135,11 +135,6 @@ user: first: 使用存取金鑰登入 Twitch.tv 帳號 second: "請確認金鑰擁有下列權限:" fail: 認證失敗,請重試 - subscriptions: - header: 訂閱 - empty: - first: 您目前無任何訂閱頻道 - second: 訂閱頻道以直接支持實況主 followedStreams: header: 追蹤中實況 empty: diff --git a/src/app/router.js b/src/app/router.js index 5d1be60653..b70c02e48b 100644 --- a/src/app/router.js +++ b/src/app/router.js @@ -15,7 +15,6 @@ export default EmberRouter.extend().map(function() { }); this.route( "user", function() { this.route( "auth" ); - this.route( "subscriptions" ); this.route( "followedStreams" ); this.route( "hostedStreams" ); this.route( "followedChannels" ); diff --git a/src/app/ui/components/list/subscription-item/component.js b/src/app/ui/components/list/subscription-item/component.js deleted file mode 100644 index f8e88f42ae..0000000000 --- a/src/app/ui/components/list/subscription-item/component.js +++ /dev/null @@ -1,56 +0,0 @@ -import { get, getWithDefault, computed } from "@ember/object"; -import { alias } from "@ember/object/computed"; -import { inject as service } from "@ember/service"; -import { twitch as twitchConfig } from "config"; -import ListItemComponent from "../-list-item/component"; -import layout from "./template.hbs"; -import "./styles.less"; - - -const { - subscription: { - "edit-url": subscriptionEditUrl, - "cancel-url": subscriptionCancelUrl - } -} = twitchConfig; - - -export default ListItemComponent.extend({ - nwjs: service(), - - layout, - - classNames: [ "subscription-item-component" ], - attributeBindings: [ "style" ], - - channel: alias( "content.channel" ), - - style: computed( "channel.profile_banner", "channel.video_banner", function() { - const banner = getWithDefault( this, - "channel.profile_banner", - getWithDefault( this, "channel.video_banner", "" ) - ); - - return ( `background-image:url("${banner}")` ).htmlSafe(); - }), - - - openBrowser( url ) { - const channel = get( this, "content.product.short_name" ); - - return this.nwjs.openBrowser( url, { - channel - }); - }, - - - actions: { - edit() { - return this.openBrowser( subscriptionEditUrl ); - }, - - cancel() { - return this.openBrowser( subscriptionCancelUrl ); - } - } -}); diff --git a/src/app/ui/components/list/subscription-item/styles.less b/src/app/ui/components/list/subscription-item/styles.less deleted file mode 100644 index 0b7faf4803..0000000000 --- a/src/app/ui/components/list/subscription-item/styles.less +++ /dev/null @@ -1,119 +0,0 @@ -@import (reference) "~ui/styles/config"; -@import (reference) "~ui/styles/themes"; - - -.subscription-item-component { - @size: 6.5rem; - @padding: 1.5rem; - @emoticon-size: 2rem; - - display: flex; - flex-flow: column; - position: relative; - min-height: 264px; - margin-bottom: 2em; - background-position: center center; - background-size: cover; - - .theme({ - .theme-mix-color( @theme-subitem-color, @theme-subitem-background ); - }); - - // no dynamic columns for this component - // this media query is required by InfiniteScrollRouteMixin, though - @media (min-width: 1px) { - width: 100%; - } - - a { - text-decoration: none; - } - - > header { - display: flex; - flex-flow: row nowrap; - align-items: flex-start; - justify-content: space-between; - flex: 1 0; - margin: @padding; - - > .logo { - display: block; - position: relative; - width: @size; - height: @size; - margin: 0; - cursor: pointer; - } - - > .buttons { - display: flex; - flex-flow: row-reverse nowrap; - align-items: flex-start; - margin: 0; - padding: .5em; - opacity: 0; - transition: opacity .2s ease-out; - - .theme({ - background: @theme-subitem-background; - }); - - > button:not(:last-of-type) { - margin-left: .5em; - } - } - } - - &:hover > header > .buttons { - opacity: 1; - } - - > .info { - padding: @padding; - - .theme({ - background: @theme-subitem-background; - }); - - > h3 { - margin: 0; - font-size: 1.75em; - - .theme({ - &, & > a:not(:hover) { - .theme-mix-color( @theme-subitem-headline-color, @theme-subitem-background ); - } - }); - } - - > .subscription { - margin: .5em 0; - - > span { - display: inline-block; - margin-right: 2em; - } - } - - > .emoticons { - display: flex; - justify-content: flex-start; - min-height: @emoticon-size; - - > li { - margin-right: .5em; - - > img { - width: auto; - height: @emoticon-size; - } - - &.no-emoticons { - font-style: italic; - line-height: @emoticon-size; - } - } - } - } -} diff --git a/src/app/ui/components/list/subscription-item/template.hbs b/src/app/ui/components/list/subscription-item/template.hbs deleted file mode 100644 index f926e424e4..0000000000 --- a/src/app/ui/components/list/subscription-item/template.hbs +++ /dev/null @@ -1,54 +0,0 @@ -
-{{#link-to "channel" channel.id tagName="div" class="logo"}} -{{preview-image src=channel.logo title=channel.display_name}} -{{/link-to}} -
-{{form-button - action=(action "cancel") - classNames="btn-danger" - icon="fa-times" - iconanim=true - title=(t "components.subscription-item.cancel") -}} -{{form-button - action=(action "edit") - classNames="btn-hint" - icon="fa-pencil" - iconanim=true - title=(t "components.subscription-item.edit") -}} -
-
-
-

{{#link-to "channel" channel.id}}{{channel.detailedName}}{{/link-to}}

-
-{{#if content.access_end}} - -{{#if hasEnded}} - {{t "components.subscription-item.access.ended"}} -{{else if content.purchase_profile.will_renew}} - {{t "components.subscription-item.access.renews" time=content.ends}} -{{else}} - {{t "components.subscription-item.access.ends" time=content.ends}} -{{/if}} - -{{else}} - {{t "components.subscription-item.subscribed"}} -{{/if}} - - {{content.product.price}} / {{content.product.period}} - - - {{t "components.subscription-item.duration" count=content.subbedFor}} - -
-
    -{{#each content.product.emoticons as |emoticon|}} -{{#if emoticon.isActive}} -
  • -{{/if}} -{{else}} -
  • {{t "components.subscription-item.no-emoticons"}}
  • -{{/each}} -
-
\ No newline at end of file diff --git a/src/app/ui/components/main-menu/component.js b/src/app/ui/components/main-menu/component.js index 49398000fc..017b3fe0d4 100644 --- a/src/app/ui/components/main-menu/component.js +++ b/src/app/ui/components/main-menu/component.js @@ -17,7 +17,6 @@ const routeHotkeys = { "featured": "1", "games": "2", "streams": "4", - "user.subscriptions": "5", "user.followedStreams": "6", "user.hostedStreams": "7", "user.followedChannels": "8", diff --git a/src/app/ui/components/main-menu/template.hbs b/src/app/ui/components/main-menu/template.hbs index d55eb3630a..a9a52471a1 100644 --- a/src/app/ui/components/main-menu/template.hbs +++ b/src/app/ui/components/main-menu/template.hbs @@ -7,7 +7,6 @@

{{t "components.main-menu.my.header"}}

    -
  • {{#link-to "user.subscriptions"}}{{t "components.main-menu.my.subscriptions"}}{{/link-to}}
  • {{#link-to "user.followedStreams"}}{{t "components.main-menu.my.live-streams"}}{{/link-to}}
  • {{#link-to "user.hostedStreams"}}{{t "components.main-menu.my.hosted-streams"}}{{/link-to}}
  • {{#link-to "user.followedChannels"}}{{t "components.main-menu.my.channels"}}{{/link-to}}
  • diff --git a/src/app/ui/routes/user/subscriptions/route.js b/src/app/ui/routes/user/subscriptions/route.js deleted file mode 100644 index 72e6caefff..0000000000 --- a/src/app/ui/routes/user/subscriptions/route.js +++ /dev/null @@ -1,43 +0,0 @@ -import UserIndexRoute from "../index/route"; -import InfiniteScrollOffsetMixin from "ui/routes/-mixins/routes/infinite-scroll/offset"; -import preload from "utils/preload"; - - -export default UserIndexRoute.extend( InfiniteScrollOffsetMixin, { - itemSelector: ".subscription-item-component", - modelName: "twitchTicket", - - async model() { - // request the subscriptions by offset - let tickets = await this._super({ unended: true }); - - // filter out unwanted ticket types (eg. twitch turbo) - tickets = this.filterFetchedContent( tickets, "product.ticket_type", "chansub" ); - - // load all channel references asynchronously (get the EmberData.PromiseObject) - await Promise.all( tickets.map( ticket => ticket.loadChannel() ) ); - // and filter out rejected promises (banned channels, etc.) - tickets = this.filterFetchedContent( tickets, "channel.isFulfilled", true ); - - // get a list of emoticons of all fetched subscriptions - const emoticons = tickets - .map( ticket => ticket.product.emoticons ) - .filter( emoticon => emoticon.isActive ) - .reduce( ( res, item ) => { - res.push( ...item.toArray() ); - return res; - }, [] ); - - // load subscription assets and emoticons in parallel - await Promise.all([ - preload( tickets, [ - "product.channel.logo", - "product.channel.profile_banner", - "product.channel.video_banner" - ]), - preload( emoticons, "url" ) - ]); - - return tickets; - } -}); diff --git a/src/app/ui/routes/user/subscriptions/template.hbs b/src/app/ui/routes/user/subscriptions/template.hbs deleted file mode 100644 index b18bcd3c47..0000000000 --- a/src/app/ui/routes/user/subscriptions/template.hbs +++ /dev/null @@ -1,14 +0,0 @@ -
    -
    -

    {{t "routes.user.subscriptions.header"}}

    -{{#quick-bar}} -{{quick-bar-homepage}} -{{/quick-bar}} -
    -{{#content-list model as |item isNewItem isDuplicateItem|}} -{{subscription-item content=item isNewItem=isNewItem isDuplicateItem=isDuplicateItem}} -{{else}} -

    {{t "routes.user.subscriptions.empty.first"}}

    -

    {{t "routes.user.subscriptions.empty.second"}}

    -{{/content-list}} -
    \ No newline at end of file diff --git a/src/app/ui/styles/themes/dark.less b/src/app/ui/styles/themes/dark.less index 8f95803280..b897537e33 100644 --- a/src/app/ui/styles/themes/dark.less +++ b/src/app/ui/styles/themes/dark.less @@ -120,10 +120,6 @@ @theme-streamitem-play-color : rgba( 255, 255, 255, 1 ); @theme-streamitem-play-stroke : rgba( 0, 0, 0, .9 ); - @theme-subitem-background : fade( @theme-background, 90% ); - @theme-subitem-color : @theme-text-color; - @theme-subitem-headline-color: @theme-headline-color; - @theme-modal-base-background: @theme-background; @theme-modal-base-color : @theme-text-color; @theme-modal-header-color : @theme-headline-color; diff --git a/src/app/ui/styles/themes/light.less b/src/app/ui/styles/themes/light.less index b31f7a8ded..734a60ed4d 100644 --- a/src/app/ui/styles/themes/light.less +++ b/src/app/ui/styles/themes/light.less @@ -120,10 +120,6 @@ @theme-streamitem-play-color : rgba( 255, 255, 255, 1 ); @theme-streamitem-play-stroke : rgba( 0, 0, 0, .9 ); - @theme-subitem-background : fade( @theme-background, 80% ); - @theme-subitem-color : @theme-text-color; - @theme-subitem-headline-color: @theme-headline-color; - @theme-modal-base-background: @theme-background; @theme-modal-base-color : @theme-text-color; @theme-modal-header-color : @theme-headline-color; diff --git a/src/config/twitch.json b/src/config/twitch.json index 7bbf350beb..b94b288a51 100644 --- a/src/config/twitch.json +++ b/src/config/twitch.json @@ -7,9 +7,7 @@ }, "emotes-url": "https://twitchemotes.com/channel/{channel}", "subscription": { - "create-url": "https://www.twitch.tv/{channel}/subscribe", - "edit-url": "https://www.twitch.tv/products/{channel}/ticket/edit", - "cancel-url": "https://www.twitch.tv/products/{channel}/ticket/edit?cancel_and_refund=true" + "create-url": "https://www.twitch.tv/{channel}/subscribe" }, "oauth": { "server-port": 65432, diff --git a/src/test/fixtures/data/models/twitch/ticket.json b/src/test/fixtures/data/models/twitch/ticket.json deleted file mode 100644 index 4111270075..0000000000 --- a/src/test/fixtures/data/models/twitch/ticket.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "request": { - "url": "https://api.twitch.tv/api/users/foobar/tickets", - "method": "GET", - "query": {} - }, - "response": { - "tickets": [ - { - "id": 1, - "access_start": null, - "access_end": "2000-02-01T00:00:00Z", - "is_gift": false, - "paid_upgrade": null, - "expired": false, - "purchase_profile": null, - "product": { - "name": "Subscription to Foo", - "short_name": "foo", - "ticket_type": "chansub", - "owner_name": "foo", - "features": { - "bitrate_access": [], - "tier": "1000", - "emoticon_set_ids": [ 1234 ], - "base_emoticon_set_id": 1234 - }, - "interval_number": 1, - "recurring": true, - "partner_login": "foo", - "price": "$4.99", - "period": "Month", - "emoticons": [ - { - "regex": "foo", - "regex_display": null, - "state": "active", - "url": "emoticon-1.png" - }, - { - "regex": "be?ar", - "regex_display": "bar", - "state": "active", - "url": "emoticon-2.png" - }, - { - "regex": "baz", - "regex_display": null, - "state": "inactive", - "url": "emoticon-3.png" - } - ] - } - }, - { - "id": 2, - "access_start": "1999-01-01T00:00:00Z", - "access_end": "2000-02-01T00:00:00Z", - "is_gift": false, - "paid_upgrade": null, - "expired": false, - "purchase_profile": null, - "product": { - "name": "Subscription to Bar", - "short_name": "bar", - "ticket_type": "chansub", - "owner_name": "bar", - "features": null, - "interval_number": 1, - "recurring": true, - "partner_login": "bar", - "price": "$4.99", - "period": "Month", - "emoticons": [] - } - }, - { - "id": 3, - "access_start": "1999-01-01T00:00:00Z", - "access_end": "2000-02-01T00:00:00Z", - "is_gift": false, - "paid_upgrade": null, - "expired": false, - "purchase_profile": { - "refundable": false, - "will_renew": true, - "paid_on": "2000-01-01T00:00:00Z", - "expired": false, - "renewal_date": "2000-02-01T00:00:00Z", - "payment_provider": "some payment provider", - "platform": "web", - "consecutive_months": 6 - }, - "product": { - "name": "Subscription to Baz", - "short_name": "baz", - "ticket_type": "chansub", - "owner_name": "baz", - "features": null, - "interval_number": 1, - "recurring": true, - "partner_login": "baz", - "price": "$4.99", - "period": "Month", - "emoticons": [] - } - } - ] - } -} diff --git a/src/test/tests/data/models/twitch/ticket.js b/src/test/tests/data/models/twitch/ticket.js deleted file mode 100644 index 68c3eb520c..0000000000 --- a/src/test/tests/data/models/twitch/ticket.js +++ /dev/null @@ -1,285 +0,0 @@ -import { module, test } from "qunit"; -import { buildOwner, runDestroy } from "test-utils"; -import { setupStore, adapterRequest } from "store-utils"; -import { FakeI18nService } from "i18n-utils"; -import sinon from "sinon"; - -import { set } from "@ember/object"; -import Service from "@ember/service"; -import Model from "ember-data/model"; -import RESTSerializer from "ember-data/serializers/rest"; -import Moment from "moment"; - -import ModelFragmentsInitializer from "init/initializers/model-fragments"; -import TwitchAdapter from "data/models/twitch/adapter"; -import TwitchTicket from "data/models/twitch/ticket/model"; -import TwitchTicketSerializer from "data/models/twitch/ticket/serializer"; -import TwitchTicketProduct from "data/models/twitch/ticket/product/fragment"; -import TwitchTicketProductEmoticon from "data/models/twitch/ticket/product/emoticon/fragment"; -import TwitchTicketProductFeatures from "data/models/twitch/ticket/product/features/fragment"; -import TwitchTicketPurchaseProfile from "data/models/twitch/ticket/purchase-profile/fragment"; -import TwitchUser from "data/models/twitch/user/model"; -import TwitchUserAdapter from "data/models/twitch/user/adapter"; -import TwitchUserSerializer from "data/models/twitch/user/serializer"; -import TwitchChannel from "data/models/twitch/channel/model"; -import TwitchChannelSerializer from "data/models/twitch/channel/serializer"; - -import TwitchTicketFixtures from "fixtures/data/models/twitch/ticket.json"; -import TwitchUserFixtures from "fixtures/data/models/twitch/user.json"; -import TwitchChannelFixtures from "fixtures/data/models/twitch/channel.json"; - - -module( "data/models/twitch/ticket", function( hooks ) { - hooks.before(function() { - Moment.locale( "en" ); - }); - - hooks.beforeEach(function( assert ) { - this.fakeTimer = sinon.useFakeTimers({ - toFake: [ "Date", "setTimeout", "clearTimeout" ], - now: Date.parse( "2000-01-01T00:00:00Z" ), - target: window - }); - - this.owner = buildOwner(); - - ModelFragmentsInitializer.initialize( this.owner ); - - this.owner.register( "service:auth", Service.extend({ - session: { - user_name: "foobar" - } - }) ); - this.owner.register( "service:i18n", FakeI18nService ); - this.owner.register( "service:settings", Service.extend() ); - this.owner.register( "model:twitch-ticket", TwitchTicket ); - this.owner.register( "adapter:twitch-ticket", TwitchAdapter.extend() ); - this.owner.register( "serializer:twitch-ticket", TwitchTicketSerializer ); - this.owner.register( "model:twitch-ticket-product", TwitchTicketProduct ); - this.owner.register( "model:twitch-ticket-product-emoticon", TwitchTicketProductEmoticon ); - this.owner.register( "model:twitch-ticket-product-features", TwitchTicketProductFeatures ); - this.owner.register( "model:twitch-ticket-purchase-profile", TwitchTicketPurchaseProfile ); - this.owner.register( "model:twitch-user", TwitchUser ); - this.owner.register( "adapter:twitch-user", TwitchUserAdapter ); - this.owner.register( "serializer:twitch-user", TwitchUserSerializer ); - this.owner.register( "model:twitch-channel", TwitchChannel ); - this.owner.register( "adapter:twitch-channel", TwitchAdapter.extend() ); - this.owner.register( "serializer:twitch-channel", TwitchChannelSerializer ); - this.owner.register( "model:twitch-stream", Model.extend() ); - this.owner.register( "serializer:twitch-stream", RESTSerializer.extend() ); - - this.env = setupStore( this.owner, { adapter: TwitchAdapter } ); - - this.env.store.adapterFor( "twitch-ticket" ).ajax = ( ...args ) => - adapterRequest( assert, TwitchTicketFixtures, ...args ); - this.env.store.adapterFor( "twitch-user" ).ajax = ( ...args ) => - adapterRequest( assert, TwitchUserFixtures[ "by-id" ], ...args ); - this.env.store.adapterFor( "twitch-channel" ).ajax = ( ...args ) => - adapterRequest( assert, TwitchChannelFixtures[ "by-id" ], ...args ); - }); - - hooks.afterEach(function() { - this.fakeTimer.restore(); - - runDestroy( this.owner ); - this.owner = this.env = null; - }); - - - test( "Adapter and Serializer", async function( assert ) { - const records = await this.env.store.query( "twitch-ticket", {} ); - - assert.propEqual( - records.map( record => record.toJSON({ includeId: true }) ), - [ - { - id: "1", - access_start: null, - access_end: "2000-02-01T00:00:00.000Z", - expired: false, - is_gift: false, - partner_login: "foo", - purchase_profile: null, - product: { - name: "Subscription to Foo", - short_name: "foo", - ticket_type: "chansub", - owner_name: "foo", - features: { - tier: "1000", - emoticon_set_ids: [ 1234 ], - base_emoticon_set_id: 1234 - }, - interval_number: 1, - recurring: true, - price: "$4.99", - period: "Month", - emoticons: [ - { - regex: "foo", - regex_display: null, - state: "active", - url: "emoticon-1.png" - }, - { - regex: "be?ar", - regex_display: "bar", - state: "active", - url: "emoticon-2.png" - }, - { - regex: "baz", - regex_display: null, - state: "inactive", - url: "emoticon-3.png" - } - ] - } - }, - { - id: "2", - access_start: "1999-01-01T00:00:00.000Z", - access_end: "2000-02-01T00:00:00.000Z", - expired: false, - is_gift: false, - partner_login: "bar", - purchase_profile: null, - product: { - name: "Subscription to Bar", - short_name: "bar", - ticket_type: "chansub", - owner_name: "bar", - features: null, - interval_number: 1, - recurring: true, - price: "$4.99", - period: "Month", - emoticons: [] - } - }, - { - id: "3", - access_start: "1999-01-01T00:00:00.000Z", - access_end: "2000-02-01T00:00:00.000Z", - expired: false, - is_gift: false, - partner_login: "baz", - purchase_profile: { - refundable: false, - paid_on: "2000-01-01T00:00:00.000Z", - expired: false, - consecutive_months: 6, - renewal_date: "2000-02-01T00:00:00.000Z", - will_renew: true - }, - product: { - name: "Subscription to Baz", - short_name: "baz", - ticket_type: "chansub", - owner_name: "baz", - features: null, - interval_number: 1, - recurring: true, - price: "$4.99", - period: "Month", - emoticons: [] - } - } - ], - "Has the correct model attributes" - ); - - assert.propEqual( - [ - this.env.store.hasRecordForId( "twitch-ticket", 1 ), - this.env.store.hasRecordForId( "twitch-ticket", 2 ), - this.env.store.hasRecordForId( "twitch-ticket", 3 ) - ], - [ true, true, true ], - "Has all Ticket records registered in the data store" - ); - - assert.strictEqual( - this.env.store.peekAll( "twitch-user" ).length, - 0, - "Does not have any TwitchUser records registered in the data store" - ); - - assert.strictEqual( - this.env.store.peekAll( "twitch-channel" ).length, - 0, - "Does not have any TwitchChannel records registered in the data store" - ); - }); - - - test( "Channel reference", async function( assert ) { - const records = await this.env.store.query( "twitch-ticket", {} ); - const [ ticketOne ] = records.toArray(); - - await ticketOne.loadChannel(); - - assert.ok( - this.env.store.hasRecordForId( "twitch-user", "foo" ), - "Has the foo TwitchUser record registered in the data store" - ); - assert.ok( - this.env.store.hasRecordForId( "twitch-channel", "1" ), - "Has the foo TwitchChannel record registered in the data store" - ); - - assert.strictEqual( - ticketOne.channel.content.name, - "foo", - "Has a channel alias" - ); - }); - - - test( "hasEnded / ends", async function( assert ) { - const records = await this.env.store.query( "twitch-ticket", {} ); - const [ ticketOne ] = records.toArray(); - - assert.notOk( ticketOne.hasEnded, "Has not ended yet" ); - assert.strictEqual( ticketOne.ends, "in a month", "Ends in a month" ); - - this.fakeTimer.setSystemTime( Date.parse( "2000-02-01T00:00:01Z" ) ); - assert.ok( ticketOne.hasEnded, "Has ended" ); - }); - - - test( "subbedFor", async function( assert ) { - const records = await this.env.store.query( "twitch-ticket", {} ); - const [ ticketOne, ticketTwo, ticketThree ] = records.toArray(); - - assert.strictEqual( ticketOne.subbedFor, 1, "Returns one if months is unkown" ); - assert.strictEqual( ticketTwo.subbedFor, 12, "Calculates months from access_start" ); - assert.strictEqual( ticketThree.subbedFor, 6, "Returns consecutive_months if it is set" ); - - set( ticketThree, "purchase_profile.consecutive_months", null ); - assert.strictEqual( - ticketThree.subbedFor, - 12, - "Falls back to access_start if consecutive_months is unset" - ); - }); - - - test( "Emoticons", async function( assert ) { - const records = await this.env.store.query( "twitch-ticket", {} ); - const [ ticketOne ] = records.toArray(); - - assert.propEqual( - ticketOne.product.emoticons.map( e => e.isActive ), - [ true, true, false ], - "Emoticons have a computed isActive property" - ); - - assert.propEqual( - ticketOne.product.emoticons.map( e => e.title ), - [ "foo", "bar", "baz" ], - "Emoticons have a computed title property" - ); - }); - -}); From f103c57404eeb73d205b6d6cf201365f6d4bbb50 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Wed, 20 Nov 2019 07:02:47 +0100 Subject: [PATCH 2/7] private api: remove hosted streams list --- .../data/models/twitch/stream-hosted/model.js | 14 -- .../models/twitch/stream-hosted/serializer.js | 17 --- src/app/locales/de/components.yml | 2 - src/app/locales/de/routes.yml | 8 - src/app/locales/en/components.yml | 2 - src/app/locales/en/routes.yml | 8 - src/app/locales/fr/components.yml | 2 - src/app/locales/fr/routes.yml | 8 - src/app/locales/zh-tw/components.yml | 2 - src/app/locales/zh-tw/routes.yml | 8 - src/app/router.js | 1 - .../components/list/stream-item/component.js | 1 - .../components/list/stream-item/styles.less | 11 +- .../components/list/stream-item/template.hbs | 3 - src/app/ui/components/main-menu/component.js | 1 - src/app/ui/components/main-menu/template.hbs | 1 - .../routes/user/followed-streams/template.hbs | 1 - .../ui/routes/user/hosted-streams/route.js | 31 ---- .../routes/user/hosted-streams/template.hbs | 20 --- .../data/models/twitch/stream-hosted.json | 69 --------- .../tests/data/models/twitch/stream-hosted.js | 139 ------------------ 21 files changed, 1 insertion(+), 348 deletions(-) delete mode 100644 src/app/data/models/twitch/stream-hosted/model.js delete mode 100644 src/app/data/models/twitch/stream-hosted/serializer.js delete mode 100644 src/app/ui/routes/user/hosted-streams/route.js delete mode 100644 src/app/ui/routes/user/hosted-streams/template.hbs delete mode 100644 src/test/fixtures/data/models/twitch/stream-hosted.json delete mode 100644 src/test/tests/data/models/twitch/stream-hosted.js diff --git a/src/app/data/models/twitch/stream-hosted/model.js b/src/app/data/models/twitch/stream-hosted/model.js deleted file mode 100644 index f8345c7803..0000000000 --- a/src/app/data/models/twitch/stream-hosted/model.js +++ /dev/null @@ -1,14 +0,0 @@ -import attr from "ember-data/attr"; -import Model from "ember-data/model"; -import { belongsTo } from "ember-data/relationships"; - - -export default Model.extend({ - display_name: attr( "string" ), - name: attr( "string" ), - // always side-load the target relation - target: belongsTo( "twitchStream", { async: true } ) - -}).reopenClass({ - toString() { return "api/users/:user_name/followed/hosting"; } -}); diff --git a/src/app/data/models/twitch/stream-hosted/serializer.js b/src/app/data/models/twitch/stream-hosted/serializer.js deleted file mode 100644 index dcf3e5c3ec..0000000000 --- a/src/app/data/models/twitch/stream-hosted/serializer.js +++ /dev/null @@ -1,17 +0,0 @@ -import TwitchSerializer from "data/models/twitch/serializer"; - - -export default TwitchSerializer.extend({ - primaryKey: "id", - - modelNameFromPayloadKey() { - return "twitchStreamHosted"; - }, - - normalize( modelClass, resourceHash, prop ) { - // get the target _id property and use it as key for the twitchStream relation - resourceHash.target = resourceHash.target._id; - - return this._super( modelClass, resourceHash, prop ); - } -}); diff --git a/src/app/locales/de/components.yml b/src/app/locales/de/components.yml index b1772cb6de..8dd5be2850 100644 --- a/src/app/locales/de/components.yml +++ b/src/app/locales/de/components.yml @@ -27,7 +27,6 @@ main-menu: my: header: Meine live-streams: Live Streams - hosted-streams: Hosts channels: Kanäle games: Spiele misc: @@ -74,7 +73,6 @@ settings-submit: share-channel: title: URL des Kanals in die Zwischenablage kopieren stream-item: - hosted-by: "gehosted von {{name}}" fps: "{{fps}} fps" details: show: Streamdetails anzeigen diff --git a/src/app/locales/de/routes.yml b/src/app/locales/de/routes.yml index c71ca1ee4f..2d1d1e4fcb 100644 --- a/src/app/locales/de/routes.yml +++ b/src/app/locales/de/routes.yml @@ -139,16 +139,8 @@ user: header: Gefolgte Streams empty: text: Die Liste der gefolgten Streams ist leer. - hosted: Von gefolgten Kanälen gehostete Streams anschauen featured: Vorgestellte Streams anschauen streams: Top-Streams anschauen - hostedStreams: - header: Gehostete Streams - empty: - text: Die Liste der gehosteten Streams ist leer. - followed: Gefolgte Streams anschauen - featured: Vorgestellete Streams anschauen - streams: Top-Streams anschauen followedChannels: header: Gefolgte Kanäle buttons: diff --git a/src/app/locales/en/components.yml b/src/app/locales/en/components.yml index 8ce843b41e..5157f21c24 100644 --- a/src/app/locales/en/components.yml +++ b/src/app/locales/en/components.yml @@ -27,7 +27,6 @@ main-menu: my: header: My live-streams: Live Streams - hosted-streams: Hosted Streams channels: Channels games: Games misc: @@ -74,7 +73,6 @@ settings-submit: share-channel: title: Copy channel url to clipboard stream-item: - hosted-by: "hosted by {{name}}" fps: "{{fps}} fps" details: show: Show stream details diff --git a/src/app/locales/en/routes.yml b/src/app/locales/en/routes.yml index 684a67d251..e2549541d0 100644 --- a/src/app/locales/en/routes.yml +++ b/src/app/locales/en/routes.yml @@ -139,14 +139,6 @@ user: header: Followed Streams empty: text: The returned list of followed streams is empty. - hosted: Watch streams being hosted by your followed channels - featured: Watch currently featured streams - streams: Watch top streams - hostedStreams: - header: Hosted Streams - empty: - text: The returned list of hosted streams is empty. - followed: Watch your followed streams featured: Watch currently featured streams streams: Watch top streams followedChannels: diff --git a/src/app/locales/fr/components.yml b/src/app/locales/fr/components.yml index b10e6dc1fa..15464eda62 100644 --- a/src/app/locales/fr/components.yml +++ b/src/app/locales/fr/components.yml @@ -27,7 +27,6 @@ main-menu: my: header: Mes live-streams: Streams live - hosted-streams: Streams Hébergés channels: Chaînes games: Jeux misc: @@ -74,7 +73,6 @@ settings-submit: share-channel: title: Copier l'url de la chaîne dans le presse-papiers stream-item: - hosted-by: "hébérgé par {{name}}" fps: "{{fps}} fps" details: show: Voir les détails du stream diff --git a/src/app/locales/fr/routes.yml b/src/app/locales/fr/routes.yml index 075742f08e..9d0385b9c9 100644 --- a/src/app/locales/fr/routes.yml +++ b/src/app/locales/fr/routes.yml @@ -139,16 +139,8 @@ user: header: Stream suivis empty: text: La liste retournée des streams est vide - hosted: Regarder les streams hébergés par les chaînes que vous suivez featured: Regarder les flux actuellement mis en avant streams: Regarder les top streams - hostedStreams: - header: Streams hébergés - empty: - text: La liste retournée des streams hébergés est vide. - followed: Regardez vos chaînes suivies - featured: Regarder les streams actuellement mis en avant - streams: Regarder les top streams followedChannels: header: Chaînes suivies buttons: diff --git a/src/app/locales/zh-tw/components.yml b/src/app/locales/zh-tw/components.yml index e2c1710ab0..520d9d12b0 100644 --- a/src/app/locales/zh-tw/components.yml +++ b/src/app/locales/zh-tw/components.yml @@ -27,7 +27,6 @@ main-menu: my: header: 我的 live-streams: 實況 - hosted-streams: 轉播 channels: 頻道 games: 遊戲 misc: @@ -74,7 +73,6 @@ settings-submit: share-channel: title: 複製頻道網址 stream-item: - hosted-by: "{{name}} 轉播中" fps: "{{fps}} fps" details: show: 顯示頻道資訊 diff --git a/src/app/locales/zh-tw/routes.yml b/src/app/locales/zh-tw/routes.yml index 0147b385f2..9352941dd4 100644 --- a/src/app/locales/zh-tw/routes.yml +++ b/src/app/locales/zh-tw/routes.yml @@ -139,14 +139,6 @@ user: header: 追蹤中實況 empty: text: 目前無追蹤中實況 - hosted: 觀看追蹤頻道正在轉播中的實況 - featured: 觀看目前的精選實況 - streams: 觀看熱門實況 - hostedStreams: - header: 轉播實況 - empty: - text: 目前無轉播實況 - followed: 觀看追蹤中實況 featured: 觀看目前的精選實況 streams: 觀看熱門實況 followedChannels: diff --git a/src/app/router.js b/src/app/router.js index b70c02e48b..c28d34a6b9 100644 --- a/src/app/router.js +++ b/src/app/router.js @@ -16,7 +16,6 @@ export default EmberRouter.extend().map(function() { this.route( "user", function() { this.route( "auth" ); this.route( "followedStreams" ); - this.route( "hostedStreams" ); this.route( "followedChannels" ); this.route( "followedGames", function() { this.route( "all" ); diff --git a/src/app/ui/components/list/stream-item/component.js b/src/app/ui/components/list/stream-item/component.js index 2ff50c8f32..fad06e67cf 100644 --- a/src/app/ui/components/list/stream-item/component.js +++ b/src/app/ui/components/list/stream-item/component.js @@ -17,7 +17,6 @@ export default ListItemComponent.extend({ classNameBindings: [ ":stream-item-component", "showGame:show-game", - "host:show-host", "settings.streams.show_flag:show-flag", "settings.streams.show_info:show-info", "infoGame:info-game", diff --git a/src/app/ui/components/list/stream-item/styles.less b/src/app/ui/components/list/stream-item/styles.less index cdfef7a445..a994f720fe 100644 --- a/src/app/ui/components/list/stream-item/styles.less +++ b/src/app/ui/components/list/stream-item/styles.less @@ -164,10 +164,6 @@ margin-left: @icon-offset; text-align: center; text-indent: -.05em; - - &.icon-host { - line-height: 1.5; - } } a, @@ -305,16 +301,11 @@ // fix play icon position &.show-game, &.info-title { - &:not(.show-host) > .preview::after { + > .preview::after { top: calc( 50% - .75rem ); } } - // fix play icon size - &.show-host > .preview::after { - font-size: 5rem; - } - // show the right info in the bottom bar &.info-game > .preview > footer > .bottom > .info-title, &.info-title > .preview > footer > .bottom > .info-game { diff --git a/src/app/ui/components/list/stream-item/template.hbs b/src/app/ui/components/list/stream-item/template.hbs index 01118ef50c..a20c029bbd 100644 --- a/src/app/ui/components/list/stream-item/template.hbs +++ b/src/app/ui/components/list/stream-item/template.hbs @@ -13,9 +13,6 @@ title=(unless expanded (unless infoTitle (if channel.status channel.status "") (if channel.game channel.game "")) "") action=(action "collapse") }} -{{#if host}} -
    {{#link-to "channel" host.id title=(t "components.stream-item.hosted-by" name=host.display_name) bubbles=false}}{{host.display_name}}{{/link-to}}
    -{{/if}}
    {{#if channel.game}}{{#link-to "games.game" channel.game title=channel.game}}{{channel.game}}{{/link-to}}{{/if}}
    diff --git a/src/app/ui/components/main-menu/component.js b/src/app/ui/components/main-menu/component.js index 017b3fe0d4..4011e705bf 100644 --- a/src/app/ui/components/main-menu/component.js +++ b/src/app/ui/components/main-menu/component.js @@ -18,7 +18,6 @@ const routeHotkeys = { "games": "2", "streams": "4", "user.followedStreams": "6", - "user.hostedStreams": "7", "user.followedChannels": "8", "user.followedGames": "9" }; diff --git a/src/app/ui/components/main-menu/template.hbs b/src/app/ui/components/main-menu/template.hbs index a9a52471a1..8561be1c58 100644 --- a/src/app/ui/components/main-menu/template.hbs +++ b/src/app/ui/components/main-menu/template.hbs @@ -8,7 +8,6 @@

    {{t "components.main-menu.my.header"}}

    • {{#link-to "user.followedStreams"}}{{t "components.main-menu.my.live-streams"}}{{/link-to}}
    • -
    • {{#link-to "user.hostedStreams"}}{{t "components.main-menu.my.hosted-streams"}}{{/link-to}}
    • {{#link-to "user.followedChannels"}}{{t "components.main-menu.my.channels"}}{{/link-to}}
    • {{#link-to "user.followedGames"}}{{t "components.main-menu.my.games"}}{{/link-to}}
    diff --git a/src/app/ui/routes/user/followed-streams/template.hbs b/src/app/ui/routes/user/followed-streams/template.hbs index 58a35a3925..ce5c8e3f9d 100644 --- a/src/app/ui/routes/user/followed-streams/template.hbs +++ b/src/app/ui/routes/user/followed-streams/template.hbs @@ -12,7 +12,6 @@ {{else}}

    {{t "routes.user.followedStreams.empty.text"}}

      -
    • {{#link-to "user.hostedStreams"}}{{t "routes.user.followedStreams.empty.hosted"}}{{/link-to}}
    • {{#link-to "featured"}}{{t "routes.user.followedStreams.empty.featured"}}{{/link-to}}
    • {{#link-to "streams"}}{{t "routes.user.followedStreams.empty.streams"}}{{/link-to}}
    diff --git a/src/app/ui/routes/user/hosted-streams/route.js b/src/app/ui/routes/user/hosted-streams/route.js deleted file mode 100644 index e441997390..0000000000 --- a/src/app/ui/routes/user/hosted-streams/route.js +++ /dev/null @@ -1,31 +0,0 @@ -import { get } from "@ember/object"; -import UserIndexRoute from "../index/route"; -import InfiniteScrollOffsetMixin from "ui/routes/-mixins/routes/infinite-scroll/offset"; -import RefreshRouteMixin from "ui/routes/-mixins/routes/refresh"; -import preload from "utils/preload"; - - -export default UserIndexRoute.extend( InfiniteScrollOffsetMixin, RefreshRouteMixin, { - itemSelector: ".stream-item-component", - modelName: "twitchStreamHosted", - - async model() { - const records = await this._super(); - await Promise.all( records - .mapBy( "target" ) - .uniqBy( "id" ) - .map( async streamPromise => { - await streamPromise.promise; - const stream = streamPromise.content; - if ( get( stream, "isLoading" ) ) { - await streamPromise; - } else { - await stream.reload(); - } - await preload( stream, "preview.mediumLatest" ); - }) - ); - - return records; - } -}); diff --git a/src/app/ui/routes/user/hosted-streams/template.hbs b/src/app/ui/routes/user/hosted-streams/template.hbs deleted file mode 100644 index 6bfda21c69..0000000000 --- a/src/app/ui/routes/user/hosted-streams/template.hbs +++ /dev/null @@ -1,20 +0,0 @@ -
    -
    -

    {{t "routes.user.hostedStreams.header"}}

    -{{headline-totals model.meta.total}} -{{#quick-bar}} -{{quick-bar-random-stream model="twitchStreamHosted"}} -{{quick-bar-homepage}} -{{/quick-bar}} -
    -{{#content-list model "target.id" true as |item isNewItem isDuplicateItem|}} -{{stream-item host=item content=item.target isNewItem=isNewItem isDuplicateItem=isDuplicateItem}} -{{else}} -

    {{t "routes.user.hostedStreams.empty.text"}}

    -
      -
    • {{#link-to "user.followedStreams"}}{{t "routes.user.hostedStreams.empty.followed"}}{{/link-to}}
    • -
    • {{#link-to "featured"}}{{t "routes.user.hostedStreams.empty.featured"}}{{/link-to}}
    • -
    • {{#link-to "streams"}}{{t "routes.user.hostedStreams.empty.streams"}}{{/link-to}}
    • -
    -{{/content-list}} -
    \ No newline at end of file diff --git a/src/test/fixtures/data/models/twitch/stream-hosted.json b/src/test/fixtures/data/models/twitch/stream-hosted.json deleted file mode 100644 index cab4c2ac45..0000000000 --- a/src/test/fixtures/data/models/twitch/stream-hosted.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "request": { - "url": "https://api.twitch.tv/api/users/foobar/followed/hosting", - "method": "GET", - "query": { } - }, - "response": { - "_links": {}, - "_total": 1000, - "hosts": [ - { - "id": 2, - "name": "bar", - "display_name": "Bar", - "logo": "logo-bar", - "target": { - "id": "foo", - "_id": 1, - "channel": { - "id": 1, - "name": "foo", - "display_name": "Foo", - "logo": "logo-foo", - "url": "url-foo" - }, - "meta_game": "game-foo", - "preview": "preview-foo", - "title": "title-foo", - "url": "url-foo", - "preview_urls": { - "small": "preview-small-foo", - "medium": "preview-medium-foo", - "large": "preview-large-foo", - "template": "preview-template-foo" - }, - "viewers": 10000 - } - }, - { - "id": 4, - "name": "qux", - "display_name": "Qux", - "logo": "logo-qux", - "target": { - "id": "baz", - "_id": 3, - "channel": { - "id": 3, - "name": "baz", - "display_name": "Baz", - "logo": "logo-baz", - "url": "url-baz" - }, - "meta_game": "game-baz", - "preview": "preview-baz", - "title": "title-baz", - "url": "url-baz", - "preview_urls": { - "small": "preview-small-baz", - "medium": "preview-medium-baz", - "large": "preview-large-baz", - "template": "preview-template-baz" - }, - "viewers": 1000 - } - } - ] - } -} diff --git a/src/test/tests/data/models/twitch/stream-hosted.js b/src/test/tests/data/models/twitch/stream-hosted.js deleted file mode 100644 index 7651adfdd2..0000000000 --- a/src/test/tests/data/models/twitch/stream-hosted.js +++ /dev/null @@ -1,139 +0,0 @@ -import { module, test } from "qunit"; -import { buildOwner, runDestroy } from "test-utils"; -import { setupStore, adapterRequest } from "store-utils"; -import { FakeI18nService } from "i18n-utils"; -import { get } from "@ember/object"; -import Service from "@ember/service"; - -import StreamHosted from "data/models/twitch/stream-hosted/model"; -import StreamHostedSerializer from "data/models/twitch/stream-hosted/serializer"; -import Stream from "data/models/twitch/stream/model"; -import StreamSerializer from "data/models/twitch/stream/serializer"; -import Channel from "data/models/twitch/channel/model"; -import ChannelSerializer from "data/models/twitch/channel/serializer"; -import imageInjector from "inject-loader?config!data/models/twitch/image/model"; -import ImageSerializer from "data/models/twitch/image/serializer"; -import TwitchAdapter from "data/models/twitch/adapter"; -import TwitchStreamHostedFixtures from "fixtures/data/models/twitch/stream-hosted.json"; -import TwitchStreamFixtures from "fixtures/data/models/twitch/stream.json"; - - -const TwitchImage = imageInjector({ - config: { - vars: {} - } -})[ "default" ]; - - -let owner, env; - - -module( "data/models/twitch/stream-hosted", { - beforeEach() { - owner = buildOwner(); - - owner.register( "service:auth", Service.extend({ - session: { - user_name: "foobar" - } - }) ); - owner.register( "service:i18n", FakeI18nService ); - owner.register( "service:settings", Service.extend() ); - owner.register( "model:twitch-stream-hosted", StreamHosted ); - owner.register( "adapter:twitch-stream-hosted", TwitchAdapter.extend() ); - owner.register( "serializer:twitch-stream-hosted", StreamHostedSerializer ); - owner.register( "model:twitch-stream", Stream ); - owner.register( "adapter:twitch-stream", TwitchAdapter.extend() ); - owner.register( "serializer:twitch-stream", StreamSerializer ); - owner.register( "model:twitch-channel", Channel ); - owner.register( "serializer:twitch-channel", ChannelSerializer ); - owner.register( "model:twitch-image", TwitchImage ); - owner.register( "serializer:twitch-image", ImageSerializer ); - - env = setupStore( owner ); - }, - - afterEach() { - runDestroy( owner ); - owner = env = null; - } -}); - - -test( "Adapter and Serializer", assert => { - - env.store.adapterFor( "twitchStreamHosted" ).ajax = ( url, method, query ) => - adapterRequest( assert, TwitchStreamHostedFixtures, url, method, query ); - - env.store.adapterFor( "twitchStream" ).ajax = ( url, method, query ) => - adapterRequest( assert, TwitchStreamFixtures[ "single" ], url, method, query ); - - return env.store.query( "twitchStreamHosted", {} ) - .then( records => { - assert.strictEqual( - get( records, "length" ), - 2, - "Returns all records" - ); - - assert.strictEqual( - get( records, "meta.total" ), - 1000, - "Recordarray has metadata with total number of games" - ); - - assert.deepEqual( - records.map( record => record.toJSON({ includeId: true }) ), - [ - { - id: "2", - target: "1", - display_name: "Bar", - name: "bar" - }, - { - id: "4", - target: "3", - display_name: "Qux", - name: "qux" - } - ], - "Models have the correct id and attributes" - ); - - assert.strictEqual( - env.store.peekAll( "twitchStream" ).get( "length" ), - 0, - "Does not have any Stream records registered in the data store" - ); - - assert.strictEqual( - env.store.peekAll( "twitchChannel" ).get( "length" ), - 0, - "Does not have any Channel records registered in the data store" - ); - - assert.strictEqual( - env.store.peekAll( "twitchImage" ).get( "length" ), - 0, - "Does not have any Image records registered in the data store" - ); - - return get( records, "firstObject.target" ) - .then( () => { - assert.ok( - env.store.hasRecordForId( "twitchStream", "1" ), - "Store has a Stream record registered after accessing the first target" - ); - assert.ok( - env.store.hasRecordForId( "twitchChannel", "1" ), - "Store has a Channel record registered after accessing the first target" - ); - assert.ok( - env.store.hasRecordForId( "twitchImage", "stream/preview/1" ), - "Store has a Image record registered after accessing the first target" - ); - }); - }); - -}); From e519b05f14712c69440a49c2f29aa0d199b4d900 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Wed, 20 Nov 2019 07:29:22 +0100 Subject: [PATCH 3/7] private api: remove followed games --- .../models/twitch/game-followed-live/model.js | 13 -- .../twitch/game-followed-live/serializer.js | 24 --- .../data/models/twitch/game-followed/model.js | 10 -- .../models/twitch/game-followed/serializer.js | 55 ------ src/app/locales/de/components.yml | 1 - src/app/locales/de/routes.yml | 13 -- src/app/locales/en/components.yml | 1 - src/app/locales/en/routes.yml | 13 -- src/app/locales/fr/components.yml | 1 - src/app/locales/fr/routes.yml | 13 -- src/app/locales/zh-tw/components.yml | 1 - src/app/locales/zh-tw/routes.yml | 13 -- src/app/router.js | 3 - .../button/follow-game/component.js | 12 -- .../ui/components/list/game-item/component.js | 14 +- src/app/ui/components/main-menu/component.js | 3 +- src/app/ui/components/main-menu/template.hbs | 1 - src/app/ui/routes/games/game/template.hbs | 2 +- .../routes/user/followed-games/all/route.js | 7 - .../user/followed-games/all/template.hbs | 8 - .../routes/user/followed-games/index/route.js | 10 -- .../user/followed-games/index/template.hbs | 8 - .../user/followed-games/loading/route.js | 1 - .../routes/user/followed-games/template.hbs | 15 -- .../models/twitch/game-followed-live.json | 32 ---- .../data/models/twitch/game-followed.json | 60 ------- .../data/models/twitch/game-followed-live.js | 122 -------------- .../tests/data/models/twitch/game-followed.js | 159 ------------------ 28 files changed, 5 insertions(+), 610 deletions(-) delete mode 100644 src/app/data/models/twitch/game-followed-live/model.js delete mode 100644 src/app/data/models/twitch/game-followed-live/serializer.js delete mode 100644 src/app/data/models/twitch/game-followed/model.js delete mode 100644 src/app/data/models/twitch/game-followed/serializer.js delete mode 100644 src/app/ui/components/button/follow-game/component.js delete mode 100644 src/app/ui/routes/user/followed-games/all/route.js delete mode 100644 src/app/ui/routes/user/followed-games/all/template.hbs delete mode 100644 src/app/ui/routes/user/followed-games/index/route.js delete mode 100644 src/app/ui/routes/user/followed-games/index/template.hbs delete mode 100644 src/app/ui/routes/user/followed-games/loading/route.js delete mode 100644 src/app/ui/routes/user/followed-games/template.hbs delete mode 100644 src/test/fixtures/data/models/twitch/game-followed-live.json delete mode 100644 src/test/fixtures/data/models/twitch/game-followed.json delete mode 100644 src/test/tests/data/models/twitch/game-followed-live.js delete mode 100644 src/test/tests/data/models/twitch/game-followed.js diff --git a/src/app/data/models/twitch/game-followed-live/model.js b/src/app/data/models/twitch/game-followed-live/model.js deleted file mode 100644 index 999a75946e..0000000000 --- a/src/app/data/models/twitch/game-followed-live/model.js +++ /dev/null @@ -1,13 +0,0 @@ -import attr from "ember-data/attr"; -import Model from "ember-data/model"; -import { belongsTo } from "ember-data/relationships"; - - -export default Model.extend({ - channels: attr( "number" ), - game: belongsTo( "twitchGameFollowed", { async: false } ), - viewers: attr( "number" ) - -}).reopenClass({ - toString() { return "api/users/:user_name/follows/games/live"; } -}); diff --git a/src/app/data/models/twitch/game-followed-live/serializer.js b/src/app/data/models/twitch/game-followed-live/serializer.js deleted file mode 100644 index cc9315de41..0000000000 --- a/src/app/data/models/twitch/game-followed-live/serializer.js +++ /dev/null @@ -1,24 +0,0 @@ -import TwitchSerializer from "data/models/twitch/serializer"; - - -export default TwitchSerializer.extend({ - modelNameFromPayloadKey() { - return "twitchGameFollowedLive"; - }, - - attrs: { - game: { deserialize: "records" } - }, - - normalize( modelClass, resourceHash, prop ) { - const foreignKey = this.store.serializerFor( "twitchGame" ).primaryKey; - - // fix payload format - resourceHash.game = { game: resourceHash.game }; - - // get the id of the embedded TwitchGame record and apply it here - resourceHash[ this.primaryKey ] = resourceHash.game.game[ foreignKey ]; - - return this._super( modelClass, resourceHash, prop ); - } -}); diff --git a/src/app/data/models/twitch/game-followed/model.js b/src/app/data/models/twitch/game-followed/model.js deleted file mode 100644 index 5ec010a491..0000000000 --- a/src/app/data/models/twitch/game-followed/model.js +++ /dev/null @@ -1,10 +0,0 @@ -import Model from "ember-data/model"; -import { belongsTo } from "ember-data/relationships"; - - -export default Model.extend({ - game: belongsTo( "twitchGame", { async: false } ) - -}).reopenClass({ - toString() { return "api/users/:user_name/follows/games"; } -}); diff --git a/src/app/data/models/twitch/game-followed/serializer.js b/src/app/data/models/twitch/game-followed/serializer.js deleted file mode 100644 index f822dda48b..0000000000 --- a/src/app/data/models/twitch/game-followed/serializer.js +++ /dev/null @@ -1,55 +0,0 @@ -import TwitchSerializer from "data/models/twitch/serializer"; - - -export default TwitchSerializer.extend({ - modelNameFromPayloadKey() { - return "twitchGameFollowed"; - }, - - attrs: { - game: { deserialize: "records" } - }, - - normalizeArrayResponse( store, primaryModelClass, payload, id, requestType ) { - // fix payload format - const follows = ( payload.follows /* istanbul ignore next */ || [] ); - delete payload.follows; - payload[ this.modelNameFromPayloadKey() ] = follows.map( game => ({ game }) ); - - return this._super( store, primaryModelClass, payload, id, requestType ); - }, - - normalizeSingleResponse( store, primaryModelClass, payload, id, requestType ) { - // fix payload format - payload = { - [ this.modelNameFromPayloadKey() ]: { game: payload } - }; - - return this._super( store, primaryModelClass, payload, id, requestType ); - }, - - normalizeCreateRecordResponse( store, primaryModelClass, payload, id, requestType ) { - const foreignKey = this.store.serializerFor( "twitchGame" ).primaryKey; - - // return an empty payload when creating a new record (we don't need the game relationship) - payload = { - [ this.modelNameFromPayloadKey() ]: { - [ this.primaryKey ]: payload[ foreignKey ] - } - }; - - // skip calls to normalizeSaveResponse -> normalizeSingleResponse - return this._normalizeResponse( store, primaryModelClass, payload, id, requestType, true ); - }, - - normalize( modelClass, resourceHash, prop ) { - if ( !resourceHash[ this.primaryKey ] ) { - const foreignKey = this.store.serializerFor( "twitchGame" ).primaryKey; - - // get the id of the embedded TwitchGame record and apply it here - resourceHash[ this.primaryKey ] = resourceHash.game[ foreignKey ]; - } - - return this._super( modelClass, resourceHash, prop ); - } -}); diff --git a/src/app/locales/de/components.yml b/src/app/locales/de/components.yml index 8dd5be2850..270a81b916 100644 --- a/src/app/locales/de/components.yml +++ b/src/app/locales/de/components.yml @@ -28,7 +28,6 @@ main-menu: header: Meine live-streams: Live Streams channels: Kanäle - games: Spiele misc: header: Sonstiges settings: Einstellungen diff --git a/src/app/locales/de/routes.yml b/src/app/locales/de/routes.yml index 2d1d1e4fcb..d2664728da 100644 --- a/src/app/locales/de/routes.yml +++ b/src/app/locales/de/routes.yml @@ -150,19 +150,6 @@ user: sort-desc: In absteigender Reihe sortieren sort-asc: In aufsteigender Reihe sortieren empty: Die Liste der gefolgten Kanäle ist leer. - followedGames: - header: Gefolgte Spiele - menu: - live: Live Spiele - all: Alle Spiele - live: - empty: - text: Die Liste der gefolgten live Spiele ist leer. - games: Top-Spiele anschauen - all: - empty: - text: Die Liste aller gefolgten Spiele ist leer. - games: Top-Spiele anschauen search: header: all: Alle Suchergebnisse diff --git a/src/app/locales/en/components.yml b/src/app/locales/en/components.yml index 5157f21c24..414960d460 100644 --- a/src/app/locales/en/components.yml +++ b/src/app/locales/en/components.yml @@ -28,7 +28,6 @@ main-menu: header: My live-streams: Live Streams channels: Channels - games: Games misc: header: Misc settings: Settings diff --git a/src/app/locales/en/routes.yml b/src/app/locales/en/routes.yml index e2549541d0..846776fde9 100644 --- a/src/app/locales/en/routes.yml +++ b/src/app/locales/en/routes.yml @@ -150,19 +150,6 @@ user: sort-desc: Sort in descending order sort-asc: Sort in ascending order empty: The returned list of followed channels is empty. - followedGames: - header: Followed Games - menu: - live: Live Games - all: All Games - live: - empty: - text: The returned list of followed live games is empty. - games: Watch top games - all: - empty: - text: The returned list of followed games is empty. - games: Watch top games search: header: all: All search results diff --git a/src/app/locales/fr/components.yml b/src/app/locales/fr/components.yml index 15464eda62..2d5ebe7b0d 100644 --- a/src/app/locales/fr/components.yml +++ b/src/app/locales/fr/components.yml @@ -28,7 +28,6 @@ main-menu: header: Mes live-streams: Streams live channels: Chaînes - games: Jeux misc: header: Divers settings: Paramètres diff --git a/src/app/locales/fr/routes.yml b/src/app/locales/fr/routes.yml index 9d0385b9c9..852398d070 100644 --- a/src/app/locales/fr/routes.yml +++ b/src/app/locales/fr/routes.yml @@ -150,19 +150,6 @@ user: sort-desc: Trier par ordre décroissant sort-asc: Trier par ordre croissant empty: La liste retournée des chînes suivie est vide. - followedGames: - header: Jeux suivis - menu: - live: Jeux en live - all: Tous les jeux - live: - empty: - text: La liste retournée de tous les jeux en live est vide. - games: Regarder les top jeux - all: - empty: - text: La liste retournée des jeux suivis est vide. - games: Regarder les top jeux search: header: all: Tous les résultat de la recherche diff --git a/src/app/locales/zh-tw/components.yml b/src/app/locales/zh-tw/components.yml index 520d9d12b0..3011cbc96f 100644 --- a/src/app/locales/zh-tw/components.yml +++ b/src/app/locales/zh-tw/components.yml @@ -28,7 +28,6 @@ main-menu: header: 我的 live-streams: 實況 channels: 頻道 - games: 遊戲 misc: header: 其他 settings: 設定 diff --git a/src/app/locales/zh-tw/routes.yml b/src/app/locales/zh-tw/routes.yml index 9352941dd4..0df9029358 100644 --- a/src/app/locales/zh-tw/routes.yml +++ b/src/app/locales/zh-tw/routes.yml @@ -150,19 +150,6 @@ user: sort-desc: 降冪排序 sort-asc: 升冪排序 empty: 目前無追隨頻道 - followedGames: - header: 追隨的遊戲 - menu: - live: 實況中遊戲 - all: 所有遊戲 - live: - empty: - text: 目前無追隨的實況中遊戲 - games: 觀看熱門實況 - all: - empty: - text: 目前無追隨的遊戲 - games: 觀看熱門實況 search: header: all: "搜尋結果: " diff --git a/src/app/router.js b/src/app/router.js index c28d34a6b9..c2c2332364 100644 --- a/src/app/router.js +++ b/src/app/router.js @@ -17,9 +17,6 @@ export default EmberRouter.extend().map(function() { this.route( "auth" ); this.route( "followedStreams" ); this.route( "followedChannels" ); - this.route( "followedGames", function() { - this.route( "all" ); - }); }); this.route( "team", { path: "/team/:team" }, function() { this.route( "members" ); diff --git a/src/app/ui/components/button/follow-game/component.js b/src/app/ui/components/button/follow-game/component.js deleted file mode 100644 index 6ec886101e..0000000000 --- a/src/app/ui/components/button/follow-game/component.js +++ /dev/null @@ -1,12 +0,0 @@ -import { alias } from "@ember/object/computed"; -import FollowButtonComponent from "../-follow-button/component"; - - -export default FollowButtonComponent.extend({ - modelName: "twitchGameFollowed", - - // model alias (component attribute) - model : alias( "game" ), - // model is a string, no game record (just use the game name as ID) - id : alias( "model" ) -}); diff --git a/src/app/ui/components/list/game-item/component.js b/src/app/ui/components/list/game-item/component.js index 97c74c5c60..2075d0c1bd 100644 --- a/src/app/ui/components/list/game-item/component.js +++ b/src/app/ui/components/list/game-item/component.js @@ -1,5 +1,4 @@ -import { get, computed } from "@ember/object"; -import { or } from "@ember/object/computed"; +import { alias, or } from "@ember/object/computed"; import { inject as service } from "@ember/service"; import ListItemComponent from "../-list-item/component"; import layout from "./template.hbs"; @@ -14,17 +13,10 @@ export default ListItemComponent.extend({ classNames: [ "game-item-component" ], - gamePath: "game", - game: computed( "content", "gamePath", function() { - let content = get( this, "content" ); - let gamePath = get( this, "gamePath" ); - - return get( content, gamePath ); - }), + game: alias( "content.game" ), hasStats: or( "content.channels", "content.viewers" ), click() { - let game = get( this, "game.name" ); - this.router.transitionTo( "games.game", game ); + this.router.transitionTo( "games.game", this.game.name ); } }); diff --git a/src/app/ui/components/main-menu/component.js b/src/app/ui/components/main-menu/component.js index 4011e705bf..9f20b0a13c 100644 --- a/src/app/ui/components/main-menu/component.js +++ b/src/app/ui/components/main-menu/component.js @@ -18,8 +18,7 @@ const routeHotkeys = { "games": "2", "streams": "4", "user.followedStreams": "6", - "user.followedChannels": "8", - "user.followedGames": "9" + "user.followedChannels": "8" }; /** @this {MainMenuComponent} */ diff --git a/src/app/ui/components/main-menu/template.hbs b/src/app/ui/components/main-menu/template.hbs index 8561be1c58..c471bf85ac 100644 --- a/src/app/ui/components/main-menu/template.hbs +++ b/src/app/ui/components/main-menu/template.hbs @@ -9,7 +9,6 @@
    • {{#link-to "user.followedStreams"}}{{t "components.main-menu.my.live-streams"}}{{/link-to}}
    • {{#link-to "user.followedChannels"}}{{t "components.main-menu.my.channels"}}{{/link-to}}
    • -
    • {{#link-to "user.followedGames"}}{{t "components.main-menu.my.games"}}{{/link-to}}

    {{t "components.main-menu.misc.header"}}

      diff --git a/src/app/ui/routes/games/game/template.hbs b/src/app/ui/routes/games/game/template.hbs index 56e6ddd41a..387b62fe0e 100644 --- a/src/app/ui/routes/games/game/template.hbs +++ b/src/app/ui/routes/games/game/template.hbs @@ -1,6 +1,6 @@
      -

      {{follow-game game=game}}{{game}}

      +

      {{game}}

      {{headline-totals model.meta.total}} {{#quick-bar}} {{quick-bar-random-stream query=(hash game=game)}} diff --git a/src/app/ui/routes/user/followed-games/all/route.js b/src/app/ui/routes/user/followed-games/all/route.js deleted file mode 100644 index 518b4cbd19..0000000000 --- a/src/app/ui/routes/user/followed-games/all/route.js +++ /dev/null @@ -1,7 +0,0 @@ -import UserFollowedGamesIndexRoute from "../index/route"; - - -export default UserFollowedGamesIndexRoute.extend({ - modelName: "twitchGameFollowed", - modelPreload: "game.box.large" -}); diff --git a/src/app/ui/routes/user/followed-games/all/template.hbs b/src/app/ui/routes/user/followed-games/all/template.hbs deleted file mode 100644 index c2fc8c0a46..0000000000 --- a/src/app/ui/routes/user/followed-games/all/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ -{{#content-list model as |item isNewItem isDuplicateItem|}} -{{game-item content=item gamePath="game" isNewItem=isNewItem isDuplicateItem=isDuplicateItem}} -{{else}} -

      {{t "routes.user.followedGames.all.empty.text"}}

      -
        -
      • {{#link-to "games"}}{{t "routes.user.followedGames.all.empty.games"}}{{/link-to}}
      • -
      -{{/content-list}} \ No newline at end of file diff --git a/src/app/ui/routes/user/followed-games/index/route.js b/src/app/ui/routes/user/followed-games/index/route.js deleted file mode 100644 index de3934eafb..0000000000 --- a/src/app/ui/routes/user/followed-games/index/route.js +++ /dev/null @@ -1,10 +0,0 @@ -import UserIndexRoute from "../../index/route"; -import InfiniteScrollOffsetMixin from "ui/routes/-mixins/routes/infinite-scroll/offset"; -import RefreshRouteMixin from "ui/routes/-mixins/routes/refresh"; - - -export default UserIndexRoute.extend( InfiniteScrollOffsetMixin, RefreshRouteMixin, { - itemSelector: ".game-item-component", - modelName: "twitchGameFollowedLive", - modelPreload: "game.game.box.large" -}); diff --git a/src/app/ui/routes/user/followed-games/index/template.hbs b/src/app/ui/routes/user/followed-games/index/template.hbs deleted file mode 100644 index 80f28a129f..0000000000 --- a/src/app/ui/routes/user/followed-games/index/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ -{{#content-list model as |item isNewItem isDuplicateItem|}} -{{game-item content=item gamePath="game.game" isNewItem=isNewItem isDuplicateItem=isDuplicateItem}} -{{else}} -

      {{t "routes.user.followedGames.live.empty.text"}}

      -
        -
      • {{#link-to "games"}}{{t "routes.user.followedGames.live.empty.games"}}{{/link-to}}
      • -
      -{{/content-list}} \ No newline at end of file diff --git a/src/app/ui/routes/user/followed-games/loading/route.js b/src/app/ui/routes/user/followed-games/loading/route.js deleted file mode 100644 index ce798563fe..0000000000 --- a/src/app/ui/routes/user/followed-games/loading/route.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from "ui/routes/loading/route"; diff --git a/src/app/ui/routes/user/followed-games/template.hbs b/src/app/ui/routes/user/followed-games/template.hbs deleted file mode 100644 index 5d748bab65..0000000000 --- a/src/app/ui/routes/user/followed-games/template.hbs +++ /dev/null @@ -1,15 +0,0 @@ -
      -
      -

      {{t "routes.user.followedGames.header"}}

      -{{#quick-bar}} -{{quick-bar-homepage}} -{{/quick-bar}} -
      -{{#sub-menu menus=(hash - index=(t "routes.user.followedGames.menu.live") - all=(t "routes.user.followedGames.menu.all") -) as |subroute name|}} - {{#link-to (concat "user.followedGames." subroute) tagName="li"}}{{name}}{{/link-to}} -{{/sub-menu}} -{{outlet}} -
      \ No newline at end of file diff --git a/src/test/fixtures/data/models/twitch/game-followed-live.json b/src/test/fixtures/data/models/twitch/game-followed-live.json deleted file mode 100644 index 9af2d46630..0000000000 --- a/src/test/fixtures/data/models/twitch/game-followed-live.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "request": { - "url": "https://api.twitch.tv/api/users/foobar/follows/games/live", - "method": "GET", - "query": {} - }, - "response": { - "_total": 1000, - "follows": [ - { - "game": { - "_id": 1, - "name": "Game A", - "box": {}, - "logo": {} - }, - "channels": 1000, - "viewers": 100000 - }, - { - "game": { - "_id": 2, - "name": "Game B", - "box": {}, - "logo": {} - }, - "channels": 100, - "viewers": 10000 - } - ] - } -} diff --git a/src/test/fixtures/data/models/twitch/game-followed.json b/src/test/fixtures/data/models/twitch/game-followed.json deleted file mode 100644 index 8157cd556c..0000000000 --- a/src/test/fixtures/data/models/twitch/game-followed.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "single": { - "request": { - "url": "https://api.twitch.tv/api/users/foobar/follows/games/some game", - "method": "GET", - "query": null - }, - "response": { - "_id": 1, - "name": "some game", - "box": {}, - "logo": {} - } - }, - "many": { - "request": { - "url": "https://api.twitch.tv/api/users/foobar/follows/games", - "method": "GET", - "query": {} - }, - "response": { - "_total": 1000, - "follows": [ - { - "_id": 2, - "name": "game a", - "box": {}, - "logo": {} - }, - { - "_id": 3, - "name": "game b", - "box": {}, - "logo": {} - } - ] - } - }, - "create": { - "request": { - "url": "https://api.twitch.tv/api/users/foobar/follows/games/new game", - "method": "PUT", - "query": {} - }, - "response": { - "_id": 1, - "name": "new game", - "box": {}, - "logo": {} - } - }, - "delete": { - "request": { - "url": "https://api.twitch.tv/api/users/foobar/follows/games/new game", - "method": "DELETE", - "query": null - }, - "response": null - } -} diff --git a/src/test/tests/data/models/twitch/game-followed-live.js b/src/test/tests/data/models/twitch/game-followed-live.js deleted file mode 100644 index 562cb8ff22..0000000000 --- a/src/test/tests/data/models/twitch/game-followed-live.js +++ /dev/null @@ -1,122 +0,0 @@ -import { module, test } from "qunit"; -import { buildOwner, runDestroy } from "test-utils"; -import { setupStore, adapterRequest } from "store-utils"; -import { get } from "@ember/object"; -import Service from "@ember/service"; - -import GameFollowedLive from "data/models/twitch/game-followed-live/model"; -import GameFollowedLiveSerializer from "data/models/twitch/game-followed-live/serializer"; -import GameFollowed from "data/models/twitch/game-followed/model"; -import GameFollowedSerializer from "data/models/twitch/game-followed/serializer"; -import Game from "data/models/twitch/game/model"; -import GameSerializer from "data/models/twitch/game/serializer"; -import imageInjector from "inject-loader?config!data/models/twitch/image/model"; -import ImageSerializer from "data/models/twitch/image/serializer"; -import TwitchAdapter from "data/models/twitch/adapter"; -import TwitchGameFollowedLiveFixtures from "fixtures/data/models/twitch/game-followed-live.json"; - - -const TwitchImage = imageInjector({ - config: { - vars: {} - } -})[ "default" ]; - - -let owner, env; - - -module( "data/models/twitch/game-followed-live", { - beforeEach() { - owner = buildOwner(); - - owner.register( "service:auth", Service.extend({ - session: { - user_name: "foobar" - } - }) ); - owner.register( "model:twitch-game-followed-live", GameFollowedLive ); - owner.register( "serializer:twitch-game-followed-live", GameFollowedLiveSerializer ); - owner.register( "model:twitch-game-followed", GameFollowed ); - owner.register( "serializer:twitch-game-followed", GameFollowedSerializer ); - owner.register( "model:twitch-game", Game ); - owner.register( "serializer:twitch-game", GameSerializer ); - owner.register( "model:twitch-image", TwitchImage ); - owner.register( "serializer:twitch-image", ImageSerializer ); - - env = setupStore( owner, { adapter: TwitchAdapter } ); - }, - - afterEach() { - runDestroy( owner ); - owner = env = null; - } -}); - - -test( "Adapter and Serializer", assert => { - - env.adapter.ajax = ( url, method, query ) => - adapterRequest( assert, TwitchGameFollowedLiveFixtures, url, method, query ); - - return env.store.query( "twitchGameFollowedLive", {} ) - .then( records => { - assert.strictEqual( - get( records, "length" ), - 2, - "Returns all records" - ); - - assert.strictEqual( - get( records, "meta.total" ), - 1000, - "Recordarray has metadata with total number of live games followed" - ); - - assert.deepEqual( - records.map( record => record.toJSON({ includeId: true }) ), - [ - { - id: "Game A", - game: "Game A", - channels: 1000, - viewers: 100000 - }, - { - id: "Game B", - game: "Game B", - channels: 100, - viewers: 10000 - } - ], - "Models have the correct id and attributes" - ); - - assert.ok( - env.store.hasRecordForId( "twitchGameFollowedLive", "Game A" ) - && env.store.hasRecordForId( "twitchGameFollowedLive", "Game B" ), - "Has all GameFollowedLive records registered in the data store" - ); - - assert.ok( - env.store.hasRecordForId( "twitchGameFollowed", "Game A" ) - && env.store.hasRecordForId( "twitchGameFollowed", "Game B" ), - "Has all GameFollowed records registered in the data store" - ); - - assert.ok( - env.store.hasRecordForId( "twitchGame", "Game A" ) - && env.store.hasRecordForId( "twitchGame", "Game B" ), - "Has all Game records registered in the data store" - ); - - assert.ok( - env.store.hasRecordForId( "twitchImage", "game/box/Game A" ) - && env.store.hasRecordForId( "twitchImage", "game/logo/Game A" ) - && env.store.hasRecordForId( "twitchImage", "game/box/Game B" ) - && env.store.hasRecordForId( "twitchImage", "game/logo/Game B" ), - "Has all image records registered in the data store" - ); - }); - -}); diff --git a/src/test/tests/data/models/twitch/game-followed.js b/src/test/tests/data/models/twitch/game-followed.js deleted file mode 100644 index b1f24e617a..0000000000 --- a/src/test/tests/data/models/twitch/game-followed.js +++ /dev/null @@ -1,159 +0,0 @@ -import { module, test } from "qunit"; -import { setupTest } from "ember-qunit"; -import { buildResolver } from "test-utils"; -import { setupStore, adapterRequest } from "store-utils"; - -import Service from "@ember/service"; - -import TwitchGameFollowed from "data/models/twitch/game-followed/model"; -import TwitchGameFollowedSerializer from "data/models/twitch/game-followed/serializer"; -import TwitchGame from "data/models/twitch/game/model"; -import TwitchGameSerializer from "data/models/twitch/game/serializer"; -import TwitchImage from "data/models/twitch/image/model"; -import TwitchImageSerializer from "data/models/twitch/image/serializer"; -import TwitchAdapter from "data/models/twitch/adapter"; -import TwitchGameFollowedFixtures from "fixtures/data/models/twitch/game-followed.json"; - - -module( "data/models/twitch/game-followed", function( hooks ) { - setupTest( hooks, { - resolver: buildResolver({ - TwitchGameFollowed, - TwitchGameFollowedSerializer, - TwitchGame, - TwitchGameSerializer, - TwitchImage, - TwitchImageSerializer - }) - }); - - hooks.beforeEach(function() { - this.owner.register( "service:auth", Service.extend({ - session: { - user_name: "foobar" - } - }) ); - - this.env = setupStore( this.owner, { adapter: TwitchAdapter } ); - }); - - - test( "Adapter and Serializer (single)", async function( assert ) { - this.env.store.adapterFor( "twitch-game-followed" ).ajax = ( url, method, query ) => - adapterRequest( assert, TwitchGameFollowedFixtures[ "single" ], url, method, query ); - - const record = await this.env.store.findRecord( "twitch-game-followed", "some game" ); - - assert.propEqual( - record.toJSON({ includeId: true }), - { - id: "some game", - game: "some game" - }, - "Record has the correct id and attributes" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-game-followed" ).mapBy( "id" ), - [ "some game" ], - "Has all TwitchGameFollowed records registered in the data store" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-game" ).mapBy( "id" ), - [ "some game" ], - "Has all TwitchGame records registered in the data store" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-image" ).mapBy( "id" ), - [ - "game/box/some game", - "game/logo/some game" - ], - "Has all TwitchImage records registered in the data store" - ); - }); - - test( "Adapter and Serializer (many)", async function( assert ) { - this.env.store.adapterFor( "twitch-game-followed" ).ajax = ( url, method, query ) => - adapterRequest( assert, TwitchGameFollowedFixtures[ "many" ], url, method, query ); - - const records = await this.env.store.query( "twitch-game-followed", {} ); - - assert.strictEqual( - records.length, - 2, - "Returns all records" - ); - assert.strictEqual( - records.meta.total, - 1000, - "Recordarray has metadata with total number of games" - ); - assert.deepEqual( - records.map( record => record.toJSON({ includeId: true }) ), - [ - { - id: "game a", - game: "game a" - }, - { - id: "game b", - game: "game b" - } - ], - "Models have the correct id and attributes" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-game-followed" ).mapBy( "id" ), - [ "game a", "game b" ], - "Has all TwitchGameFollowed records registered in the data store" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-game" ).mapBy( "id" ), - [ "game a", "game b" ], - "Has all TwitchGame records registered in the data store" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-image" ).mapBy( "id" ), - [ - "game/box/game a", - "game/logo/game a", - "game/box/game b", - "game/logo/game b" - ], - "Has all TwitchImage records registered in the data store" - ); - }); - - test( "Create and delete records", async function( assert ) { - const { create: fixturesCreate, delete: fixturesDelete } = TwitchGameFollowedFixtures; - const adapter = this.env.store.adapterFor( "twitch-game-followed" ); - - adapter.ajax = ( ...args ) => adapterRequest( assert, fixturesCreate, ...args ); - const record = this.env.store.createRecord( "twitch-game-followed", { id: "new game" } ); - await record.save(); - - assert.propEqual( - record.toJSON({ includeId: true }), - { - id: "new game", - game: null - }, - "Record has the correct id and no game relationship" - ); - assert.propEqual( - this.env.store.peekAll( "twitch-game-followed" ).mapBy( "id" ), - [ "new game" ], - "Has the new record registered in the data store" - ); - - adapter.ajax = ( ...args ) => adapterRequest( assert, fixturesDelete, ...args ); - await record.destroyRecord(); - - assert.propEqual( - this.env.store.peekAll( "twitch-game-followed" ).mapBy( "id" ), - [], - "Has the new record registered in the data store" - ); - }); - -}); From 75a38c1f7984376ed74e8702c00f142fe8c6e564 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Wed, 20 Nov 2019 07:44:56 +0100 Subject: [PATCH 4/7] private api: remove channel panels --- package.json | 1 - .../models/twitch/channel-panel/adapter.js | 21 ------ .../data/models/twitch/channel-panel/model.js | 15 ---- .../models/twitch/channel-panel/serializer.js | 28 ------- .../channel/channel-panel-item/component.js | 47 ------------ .../channel/channel-panel-item/styles.less | 53 ------------- .../channel/channel-panel-item/template.hbs | 9 --- .../channel/channel-panels/component.js | 36 --------- .../channel/channel-panels/template.hbs | 3 - src/app/ui/routes/channel/index/controller.js | 1 - src/app/ui/routes/channel/index/route.js | 15 +--- src/app/ui/routes/channel/index/template.hbs | 7 +- .../data/models/twitch/channel-panel.json | 37 ---------- .../tests/data/models/twitch/channel-panel.js | 74 ------------------- yarn.lock | 39 ---------- 15 files changed, 2 insertions(+), 384 deletions(-) delete mode 100644 src/app/data/models/twitch/channel-panel/adapter.js delete mode 100644 src/app/data/models/twitch/channel-panel/model.js delete mode 100644 src/app/data/models/twitch/channel-panel/serializer.js delete mode 100644 src/app/ui/components/channel/channel-panel-item/component.js delete mode 100644 src/app/ui/components/channel/channel-panel-item/styles.less delete mode 100644 src/app/ui/components/channel/channel-panel-item/template.hbs delete mode 100644 src/app/ui/components/channel/channel-panels/component.js delete mode 100644 src/app/ui/components/channel/channel-panels/template.hbs delete mode 100644 src/test/fixtures/data/models/twitch/channel-panel.json delete mode 100644 src/test/tests/data/models/twitch/channel-panel.js diff --git a/package.json b/package.json index dea58c9f9c..f8f8b60ae0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "flag-icon-css": "2.8.0", "font-awesome": "4.7.0", "growly": "1.3.0", - "masonry-layout": "4.2.0", "minimist": "1.2.0", "moment": "2.21.0", "roboto-fontface": "0.8.0", diff --git a/src/app/data/models/twitch/channel-panel/adapter.js b/src/app/data/models/twitch/channel-panel/adapter.js deleted file mode 100644 index 9be0582ecb..0000000000 --- a/src/app/data/models/twitch/channel-panel/adapter.js +++ /dev/null @@ -1,21 +0,0 @@ -import TwitchAdapter from "data/models/twitch/adapter"; - - -export default TwitchAdapter.extend({ - urlFragments: { - channel( type, id, data ) { - return data.channel; - } - }, - - query( store, type, query ) { - const url = this.buildURL( type, null, null, "query", query ); - query = this.sortQueryParams ? this.sortQueryParams( query ) : query; - - return this.ajax( url, "GET", { data: {} } ); - }, - - urlForQuery( query, type ) { - return this._buildURL( type, null, query ); - } -}); diff --git a/src/app/data/models/twitch/channel-panel/model.js b/src/app/data/models/twitch/channel-panel/model.js deleted file mode 100644 index 76294cc404..0000000000 --- a/src/app/data/models/twitch/channel-panel/model.js +++ /dev/null @@ -1,15 +0,0 @@ -import attr from "ember-data/attr"; -import Model from "ember-data/model"; - - -export default Model.extend({ - display_order: attr( "number" ), - html_description: attr( "string" ), - image: attr( "string" ), - kind: attr( "string" ), - link: attr( "string" ), - title: attr( "string" ) - -}).reopenClass({ - toString() { return "api/channels/:channel/panels"; } -}); diff --git a/src/app/data/models/twitch/channel-panel/serializer.js b/src/app/data/models/twitch/channel-panel/serializer.js deleted file mode 100644 index dafe64244c..0000000000 --- a/src/app/data/models/twitch/channel-panel/serializer.js +++ /dev/null @@ -1,28 +0,0 @@ -import TwitchSerializer from "data/models/twitch/serializer"; - - -export default TwitchSerializer.extend({ - modelNameFromPayloadKey() { - return "twitchChannelPanel"; - }, - - normalizeResponse( store, primaryModelClass, payload, id, requestType ) { - // fix payload format - payload = { - twitchChannelPanel: payload - }; - - return this._super( store, primaryModelClass, payload, id, requestType ); - }, - - normalize( modelClass, resourceHash, prop ) { - const data = resourceHash.data; - if ( data ) { - resourceHash.title = data.title; - resourceHash.image = data.image; - resourceHash.link = data.link; - } - - return this._super( modelClass, resourceHash, prop ); - } -}); diff --git a/src/app/ui/components/channel/channel-panel-item/component.js b/src/app/ui/components/channel/channel-panel-item/component.js deleted file mode 100644 index 243bc6ee1f..0000000000 --- a/src/app/ui/components/channel/channel-panel-item/component.js +++ /dev/null @@ -1,47 +0,0 @@ -import { get } from "@ember/object"; -import { inject as service } from "@ember/service"; -import EmbeddedHtmlLinksComponent from "ui/components/link/embedded-html-links/component"; -import layout from "./template.hbs"; -import "./styles.less"; - - -export default EmbeddedHtmlLinksComponent.extend({ - /** @type {NwjsService} */ - nwjs: service(), - /** @type {RouterService} */ - router: service(), - - layout, - - tagName: "li", - classNames: [ "channel-panel-item-component" ], - - contextMenu( event ) { - const target = event.target; - if ( target.tagName === "IMG" && target.classList.contains( "withLink" ) ) { - return this.linkContentMenu( event, get( this, "panel.link" ) ); - } - if ( target.tagName === "A" && target.classList.contains( "external-link" ) ) { - return this.linkContentMenu( event, target.href ); - } - }, - - linkContentMenu( event, url ) { - this.nwjs.contextMenu( event, [ - { - label: [ "contextmenu.open-in-browser" ], - click: () => this.nwjs.openBrowser( url ) - }, - { - label: [ "contextmenu.copy-link-address" ], - click: () => this.nwjs.clipboard.set( url ) - } - ]); - }, - - actions: { - openBrowser( url ) { - this.router.openBrowserOrTransitionToChannel( url ); - } - } -}); diff --git a/src/app/ui/components/channel/channel-panel-item/styles.less b/src/app/ui/components/channel/channel-panel-item/styles.less deleted file mode 100644 index 62e1e70173..0000000000 --- a/src/app/ui/components/channel/channel-panel-item/styles.less +++ /dev/null @@ -1,53 +0,0 @@ - -.channel-panel-item-component { - // width in pixels - width: 320px; - margin: 0 3.125em 2em 0; - - > * { - max-width: 100%; - margin: 0 auto; - } - - .title { - font-size: 1.333em; - - > a { - font-weight: lighter; - text-decoration: none; - color: inherit; - } - } - - img { - display: block; - - &.withLink { - cursor: pointer; - } - } - - .title + img { - margin-top: 1em; - } - - .description { - padding: 1em 0; - - h1 { font-size: 1.25rem; } - h2 { font-size: 1.125rem; } - h3, h4 { font-size: 1rem; } - - ul, ol { - margin-left: -1em; - } - - a { - &, - & b, - & strong { - font-weight: inherit; - } - } - } -} diff --git a/src/app/ui/components/channel/channel-panel-item/template.hbs b/src/app/ui/components/channel/channel-panel-item/template.hbs deleted file mode 100644 index 98c6473b23..0000000000 --- a/src/app/ui/components/channel/channel-panel-item/template.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{{#if panel.title}} -{{#selectable-text tagName="h3" class="title"}}{{#if (bool-and panel.link (bool-not panel.image))}}{{#external-link url=panel.link}}{{panel.title}}{{/external-link}}{{else}}{{panel.title}}{{/if}}{{/selectable-text}} -{{/if}} -{{#if panel.image}} - -{{/if}} -{{#if panel.html_description}} -{{#selectable-text class="description"}}{{{panel.html_description}}}{{/selectable-text}} -{{/if}} \ No newline at end of file diff --git a/src/app/ui/components/channel/channel-panels/component.js b/src/app/ui/components/channel/channel-panels/component.js deleted file mode 100644 index baaff51fbf..0000000000 --- a/src/app/ui/components/channel/channel-panels/component.js +++ /dev/null @@ -1,36 +0,0 @@ -import Component from "@ember/component"; -import { on } from "@ember/object/evented"; -import { scheduleOnce } from "@ember/runloop"; -import { inject as service } from "@ember/service"; -import Masonry from "masonry-layout"; -import layout from "./template.hbs"; - - -export default Component.extend({ - /** @type {RouterService} */ - router: service(), - - layout, - - tagName: "section", - classNames: [ - "channel-panels-component" - ], - - _masonry: on( "didInsertElement", function() { - const container = this.element.querySelector( "ul" ); - scheduleOnce( "afterRender", function() { - return new Masonry( container, { - itemSelector: ".channel-panel-item-component", - columnWidth: ".channel-panel-item-component", - transitionDuration: 0 - }); - }); - }), - - actions: { - openBrowser( url ) { - this.router.openBrowserOrTransitionToChannel( url ); - } - } -}); diff --git a/src/app/ui/components/channel/channel-panels/template.hbs b/src/app/ui/components/channel/channel-panels/template.hbs deleted file mode 100644 index 527e862d38..0000000000 --- a/src/app/ui/components/channel/channel-panels/template.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{#content-list panels float=false infiniteScroll=false as |item|}} - {{channel-panel-item panel=item}} -{{/content-list}} \ No newline at end of file diff --git a/src/app/ui/routes/channel/index/controller.js b/src/app/ui/routes/channel/index/controller.js index 0453406e0e..cb83cbbc94 100644 --- a/src/app/ui/routes/channel/index/controller.js +++ b/src/app/ui/routes/channel/index/controller.js @@ -12,7 +12,6 @@ export default Controller.extend({ stream: alias( "model.stream" ), channel: alias( "model.channel" ), - panels: alias( "model.panels" ), age: computed( "channel.created_at", function() { const createdAt = get( this, "channel.created_at" ); diff --git a/src/app/ui/routes/channel/index/route.js b/src/app/ui/routes/channel/index/route.js index a9d2f2d957..f4ba7f0328 100644 --- a/src/app/ui/routes/channel/index/route.js +++ b/src/app/ui/routes/channel/index/route.js @@ -1,25 +1,12 @@ import { getOwner } from "@ember/application"; -import { get } from "@ember/object"; import Route from "@ember/routing/route"; -import preload from "utils/preload"; export default Route.extend({ async model() { - const store = get( this, "store" ); const { stream, channel } = this.modelFor( "channel" ); - const name = get( channel, "name" ); - // panels are still referenced by channel name in the private API namespace - const records = await store.query( "twitchChannelPanel", { channel: name } ); - const panels = await Promise.all( records - .filterBy( "kind", "default" ) - .sortBy( "display_order" ) - // preload all panel images - .map( panel => preload( panel, "image" ) ) - ); - - return { stream, channel, panels }; + return { stream, channel }; }, refresh() { diff --git a/src/app/ui/routes/channel/index/template.hbs b/src/app/ui/routes/channel/index/template.hbs index 49545d6f32..c8abba5638 100644 --- a/src/app/ui/routes/channel/index/template.hbs +++ b/src/app/ui/routes/channel/index/template.hbs @@ -48,9 +48,4 @@ {{follow-channel channel=channel}}
    - -{{#if panels.length}} -
    -{{channel-panels panels=panels}} -
    -{{/if}} \ No newline at end of file + \ No newline at end of file diff --git a/src/test/fixtures/data/models/twitch/channel-panel.json b/src/test/fixtures/data/models/twitch/channel-panel.json deleted file mode 100644 index 0f08517d5c..0000000000 --- a/src/test/fixtures/data/models/twitch/channel-panel.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "request": { - "url": "https://api.twitch.tv/api/channels/foo/panels", - "method": "GET", - "query": {} - }, - "response": [ - { - "_id": 1, - "display_order": 1, - "kind": "default", - "html_description": "description-html-1", - "user_id": 1, - "data": { - "link": "url-1", - "image": "image-1", - "title": "title-1", - "description": "description-markdown-1" - }, - "channel": "foo" - }, - { - "_id": 2, - "display_order": 2, - "kind": "default", - "html_description": null, - "user_id": 1, - "data": { - "link": "url-2", - "image": "image-2", - "title": "", - "description": "" - }, - "channel": "foo" - } - ] -} diff --git a/src/test/tests/data/models/twitch/channel-panel.js b/src/test/tests/data/models/twitch/channel-panel.js deleted file mode 100644 index 5fadd54361..0000000000 --- a/src/test/tests/data/models/twitch/channel-panel.js +++ /dev/null @@ -1,74 +0,0 @@ -import { module, test } from "qunit"; -import { buildOwner, runDestroy } from "test-utils"; -import { setupStore, adapterRequest } from "store-utils"; -import { get } from "@ember/object"; -import Service from "@ember/service"; - -import ChannelPanel from "data/models/twitch/channel-panel/model"; -import ChannelPanelAdapter from "data/models/twitch/channel-panel/adapter"; -import ChannelPanelSerializer from "data/models/twitch/channel-panel/serializer"; -import TwitchChannelPanelFixtures from "fixtures/data/models/twitch/channel-panel.json"; - - -let owner, env; - - -module( "data/models/twitch/channel-panel", { - beforeEach() { - owner = buildOwner(); - - owner.register( "service:auth", Service.extend() ); - owner.register( "model:twitch-channel-panel", ChannelPanel ); - owner.register( "adapter:twitch-channel-panel", ChannelPanelAdapter ); - owner.register( "serializer:twitch-channel-panel", ChannelPanelSerializer ); - - env = setupStore( owner ); - }, - - afterEach() { - runDestroy( owner ); - owner = env = null; - } -}); - - -test( "Adapter and Serializer", assert => { - - env.store.adapterFor( "twitchChannelPanel" ).ajax = ( url, method, query ) => - adapterRequest( assert, TwitchChannelPanelFixtures, url, method, query ); - - return env.store.query( "twitchChannelPanel", { channel: "foo" } ) - .then( records => { - assert.strictEqual( - get( records, "length" ), - 2, - "Returns all records" - ); - - assert.deepEqual( - records.map( record => record.toJSON({ includeId: true }) ), - [ - { - id: "1", - display_order: 1, - kind: "default", - html_description: "description-html-1", - link: "url-1", - image: "image-1", - title: "title-1" - }, - { - id: "2", - display_order: 2, - kind: "default", - html_description: null, - link: "url-2", - image: "image-2", - title: "" - } - ], - "Records have the correct id and attributes" - ); - }); - -}); diff --git a/yarn.lock b/yarn.lock index 24cbe98a7e..966ccc2a8c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3886,11 +3886,6 @@ des.js@^1.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" -desandro-matches-selector@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/desandro-matches-selector/-/desandro-matches-selector-2.0.2.tgz#717beed4dc13e7d8f3762f707a6d58a6774218e1" - integrity sha1-cXvu1NwT59jzdi9wem1YpndCGOE= - detect-file@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" @@ -4773,11 +4768,6 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= -ev-emitter@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/ev-emitter/-/ev-emitter-1.1.1.tgz#8f18b0ce5c76a5d18017f71c0a795c65b9138f2a" - integrity sha512-ipiDYhdQSCZ4hSbX4rMW+XzNKMD1prg/sTvoVmSLkuQ1MVlwjJQQA+sW8tMYR3BLUr9KjodFV4pvzunvRhd33Q== - eventemitter2@~0.4.13: version "0.4.14" resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-0.4.14.tgz#8f61b75cde012b2e9eb284d4545583b5643b61ab" @@ -5135,13 +5125,6 @@ findup-sync@~0.3.0: dependencies: glob "~5.0.0" -fizzy-ui-utils@^2.0.0: - version "2.0.7" - resolved "https://registry.yarnpkg.com/fizzy-ui-utils/-/fizzy-ui-utils-2.0.7.tgz#7df45dcc4eb374a08b65d39bb9a4beedf7330505" - integrity sha512-CZXDVXQ1If3/r8s0T+v+qVeMshhfcuq0rqIFgJnrtd+Bu8GmDmqMjntjUePypVtjHXKJ6V4sw9zeyox34n9aCg== - dependencies: - desandro-matches-selector "^2.0.0" - flag-icon-css@2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/flag-icon-css/-/flag-icon-css-2.8.0.tgz#ec10c20fe417ade787a095200630069ca436a569" @@ -5364,11 +5347,6 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" -get-size@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/get-size/-/get-size-2.0.3.tgz#54a1d0256b20ea7ac646516756202769941ad2ef" - integrity sha512-lXNzT/h/dTjTxRbm9BXb+SGxxzkm97h/PCIKtlN/CBCxxmkkIVV21udumMS93MuVTDX583gqc94v3RjuHmI+2Q== - get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" @@ -7082,14 +7060,6 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -masonry-layout@4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/masonry-layout/-/masonry-layout-4.2.0.tgz#43835c6b6e0d72eff2c31a118c8000cccc4ab965" - integrity sha1-Q4Nca24Ncu/ywxoRjIAAzMxKuWU= - dependencies: - get-size "^2.0.2" - outlayer "^2.1.0" - matcher-collection@^1.0.0: version "1.0.5" resolved "https://registry.yarnpkg.com/matcher-collection/-/matcher-collection-1.0.5.tgz#2ee095438372cb8884f058234138c05c644ec339" @@ -7857,15 +7827,6 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -outlayer@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/outlayer/-/outlayer-2.1.1.tgz#29863b6de10ea5dadfffcadfa0d728907387e9a2" - integrity sha1-KYY7beEOpdrf/8rfoNcokHOH6aI= - dependencies: - ev-emitter "^1.0.0" - fizzy-ui-utils "^2.0.0" - get-size "^2.0.2" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" From 7ba5576472c824d2d710c90a70b4292a6b9c27fc Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Thu, 21 Nov 2019 04:20:03 +0100 Subject: [PATCH 5/7] Fix homepage settings of removed routes --- .../initializers/localstorage/settings.js | 7 +- .../initializers/localstorage/settings.js | 71 ++++++++----------- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/app/init/initializers/localstorage/settings.js b/src/app/init/initializers/localstorage/settings.js index b5a4ceae6e..ecab43c0d4 100644 --- a/src/app/init/initializers/localstorage/settings.js +++ b/src/app/init/initializers/localstorage/settings.js @@ -129,7 +129,12 @@ function fixAttributes( settings ) { gui.minimizetotray = !!gui.minimizetotray; } if ( hasOwnProperty.call( gui, "homepage" ) ) { - if ( gui.homepage === "/user/following" ) { + if ( + gui.homepage === "/user/following" + || gui.homepage === "/user/subscriptions" + || gui.homepage === "/user/hostedStreams" + || /^\/user\/followedGames($|\/.*)/.test( gui.homepage ) + ) { gui.homepage = "/user/followedStreams"; } else if ( /^\/communities($|\/.*)/.test( gui.homepage ) ) { gui.homepage = "/"; diff --git a/src/test/tests/init/initializers/localstorage/settings.js b/src/test/tests/init/initializers/localstorage/settings.js index abf47f53a8..a8e9398699 100644 --- a/src/test/tests/init/initializers/localstorage/settings.js +++ b/src/test/tests/init/initializers/localstorage/settings.js @@ -333,8 +333,7 @@ test( "Fixes attributes", function( assert ) { const a = { gui: { minimize: false, - minimizetotray: 1, - homepage: "/user/following" + minimizetotray: 1 }, streaming: { quality: 1 @@ -362,8 +361,7 @@ test( "Fixes attributes", function( assert ) { { gui: { minimize: 0, - minimizetotray: true, - homepage: "/user/followedStreams" + minimizetotray: true }, streaming: { quality: "high", @@ -434,45 +432,36 @@ test( "Fixes attributes", function( assert ) { "Fixes old player preset structure" ); - const c = { - gui: { - homepage: "/communities" - } - }; - updateSettings( c ); - assert.propEqual( - c, - { - gui: { - homepage: "/" - }, - streaming: {}, - streams: {}, - chat: {}, - notification: {} - }, - "Fixes homepage of removed communities route" - ); - - const d = { - gui: { - homepage: "/communities/all" - } - }; - updateSettings( d ); - assert.propEqual( - d, - { + const guiHomepages = [ + [ "/communities", "/" ], + [ "/communities/all", "/" ], + [ "/user/following", "/user/followedStreams" ], + [ "/user/subscriptions", "/user/followedStreams" ], + [ "/user/hostedStreams", "/user/followedStreams" ], + [ "/user/followedGames", "/user/followedStreams" ], + [ "/user/followedGames/all", "/user/followedStreams" ] + ]; + for ( const [ hpOld, hpNew ] of guiHomepages ) { + const data = { gui: { - homepage: "/" + homepage: hpOld + } + }; + updateSettings( data ); + assert.propEqual( + data, + { + gui: { + homepage: hpNew + }, + streaming: {}, + streams: {}, + chat: {}, + notification: {} }, - streaming: {}, - streams: {}, - chat: {}, - notification: {} - }, - "Fixes homepage of removed communities route" - ); + `Fixes homepage of old route ${hpOld}` + ); + } const guiDefaultTheme = { gui: { From bdb989151549b9fa52ce97d55f9001f790afd5ae Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Thu, 21 Nov 2019 04:38:15 +0100 Subject: [PATCH 6/7] Reformat main menu --- src/app/locales/de/components.yml | 6 +++--- src/app/locales/en/components.yml | 6 +++--- src/app/locales/fr/components.yml | 6 +++--- src/app/locales/zh-tw/components.yml | 6 +++--- src/app/ui/components/main-menu/template.hbs | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/locales/de/components.yml b/src/app/locales/de/components.yml index 270a81b916..baaec65767 100644 --- a/src/app/locales/de/components.yml +++ b/src/app/locales/de/components.yml @@ -24,9 +24,9 @@ main-menu: featured: Vorgestellt games: Spiele streams: Streams - my: - header: Meine - live-streams: Live Streams + followed: + header: Gefolgte + streams: Streams channels: Kanäle misc: header: Sonstiges diff --git a/src/app/locales/en/components.yml b/src/app/locales/en/components.yml index 414960d460..7642a170ae 100644 --- a/src/app/locales/en/components.yml +++ b/src/app/locales/en/components.yml @@ -24,9 +24,9 @@ main-menu: featured: Featured games: Games streams: Streams - my: - header: My - live-streams: Live Streams + followed: + header: Followed + streams: Streams channels: Channels misc: header: Misc diff --git a/src/app/locales/fr/components.yml b/src/app/locales/fr/components.yml index 2d5ebe7b0d..73cac81b02 100644 --- a/src/app/locales/fr/components.yml +++ b/src/app/locales/fr/components.yml @@ -24,9 +24,9 @@ main-menu: featured: En avant games: Jeux streams: Streams - my: - header: Mes - live-streams: Streams live + followed: + header: Suivis + streams: Streams channels: Chaînes misc: header: Divers diff --git a/src/app/locales/zh-tw/components.yml b/src/app/locales/zh-tw/components.yml index 3011cbc96f..e42fa56a8b 100644 --- a/src/app/locales/zh-tw/components.yml +++ b/src/app/locales/zh-tw/components.yml @@ -24,9 +24,9 @@ main-menu: featured: 精選 games: 遊戲 streams: 實況中 - my: - header: 我的 - live-streams: 實況 + followed: + header: 追隨中 + streams: 實況中 channels: 頻道 misc: header: 其他 diff --git a/src/app/ui/components/main-menu/template.hbs b/src/app/ui/components/main-menu/template.hbs index c471bf85ac..639074d666 100644 --- a/src/app/ui/components/main-menu/template.hbs +++ b/src/app/ui/components/main-menu/template.hbs @@ -5,10 +5,10 @@
  • {{#link-to "games"}}{{t "components.main-menu.browse.games"}}{{/link-to}}
  • {{#link-to "streams"}}{{t "components.main-menu.browse.streams"}}{{/link-to}}
-

{{t "components.main-menu.my.header"}}

+

{{t "components.main-menu.followed.header"}}

    -
  • {{#link-to "user.followedStreams"}}{{t "components.main-menu.my.live-streams"}}{{/link-to}}
  • -
  • {{#link-to "user.followedChannels"}}{{t "components.main-menu.my.channels"}}{{/link-to}}
  • +
  • {{#link-to "user.followedStreams"}}{{t "components.main-menu.followed.streams"}}{{/link-to}}
  • +
  • {{#link-to "user.followedChannels"}}{{t "components.main-menu.followed.channels"}}{{/link-to}}

{{t "components.main-menu.misc.header"}}

    From 037ef047ef2a53f8b4bf4d214e5ddb1e21399941 Mon Sep 17 00:00:00 2001 From: bastimeyer Date: Thu, 21 Nov 2019 05:05:37 +0100 Subject: [PATCH 7/7] Reorder main menu hotkeys --- src/app/ui/components/main-menu/component.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/app/ui/components/main-menu/component.js b/src/app/ui/components/main-menu/component.js index 9f20b0a13c..46e1d3ff3a 100644 --- a/src/app/ui/components/main-menu/component.js +++ b/src/app/ui/components/main-menu/component.js @@ -6,9 +6,6 @@ import layout from "./template.hbs"; import "./styles.less"; -const { isArray } = Array; - - const routeHotkeys = { "about": "F1", "watching": "F10", @@ -16,9 +13,9 @@ const routeHotkeys = { "settings": "F12", "featured": "1", "games": "2", - "streams": "4", - "user.followedStreams": "6", - "user.followedChannels": "8" + "streams": "3", + "user.followedStreams": "4", + "user.followedChannels": "5" }; /** @this {MainMenuComponent} */ @@ -77,7 +74,7 @@ export default Component.extend( HotkeyMixin, /** @class MainMenuComponent */ { }, ...Object.keys( routeHotkeys ).map( route => ({ key: routeHotkeys[ route ], - force: !isArray( routeHotkeys[ route ] ), + force: true, /** @this {MainMenuComponent} */ action() { this.router.transitionTo( route );