Skip to content

Commit

Permalink
Merge pull request #2937 from CKY-/v5-catagory-change
Browse files Browse the repository at this point in the history
feat: allow stream categories to be set to empty
  • Loading branch information
zunderscore authored Jan 1, 2025
2 parents 517b461 + feea576 commit cf1b9d1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
17 changes: 13 additions & 4 deletions src/backend/effects/builtin/twitch/stream-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import twitchApi from "../../../twitch-api/api";
import eventsManager from "../../../events/EventManager";

const model: EffectType<{
mode: "specific" | "custom";
mode: "specific" | "custom" | "clear";
gameId: string;
gameName: string;
}> = {
Expand All @@ -30,6 +30,10 @@ const model: EffectType<{
<input type="radio" ng-model="effect.mode" value="custom"/>
<div class="control__indicator"></div>
</label>
<label class="control-fb control--radio">Clear category
<input type="radio" ng-model="effect.mode" value="clear"/>
<div class="control__indicator"></div>
</label>
</div>
</eos-container>
Expand Down Expand Up @@ -97,11 +101,16 @@ const model: EffectType<{
await twitchApi.channels.updateChannelInformation({
gameId: event.effect.gameId
});
} else {
const categories = await twitchApi.categories.searchCategories(event.effect.gameName.trim());
} else if (event.effect.mode === "clear" || event.effect.mode === "custom" && !event.effect.gameName) {
//user left the gamename blank
await twitchApi.channels.updateChannelInformation({
gameId: ''
});
} else if (event.effect.mode === "custom") {
const categories = await twitchApi.categories.searchCategories(event.effect.gameName?.trim());
if (categories?.length) {
const category =
categories.find((c) => c.name.toLowerCase() === event.effect.gameName.toLowerCase()) ??
categories.find(c => c.name.toLowerCase() === event.effect.gameName.toLowerCase()) ??
categories[0];

if (!category) {
Expand Down
49 changes: 33 additions & 16 deletions src/gui/app/directives/modals/misc/edit-stream-info-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,31 @@
<div class="form-group">
<label for="game" class="control-label">Category</label>
<ui-select ng-model="$ctrl.selectedGame" required input-id="game" theme="bootstrap" spinner-enabled="true" on-select="$ctrl.gameSelected($item)">
<ui-select-match placeholder="Search for category...">
<div style="height: 25px; display:flex; flex-direction: row; align-items: center;">
<img style="height: 21px; width: 21px; border-radius: 5px; margin-right:5px;" ng-src="{{$select.selected.boxArtUrl}}">
<div style="font-weight: 100;font-size: 17px;">{{$select.selected.name}}</div>
</div>
</ui-select-match>
<ui-select-choices minimum-input-length="1" repeat="game in $ctrl.games | filter: $select.search" refresh="$ctrl.searchGames($select.search)" refresh-delay="200" style="position:relative;">
<div style="height: 35px; display:flex; flex-direction: row; align-items: center;">
<img style="height: 30px; width: 30px; border-radius: 5px; margin-right:10px;" ng-src="{{game.boxArtUrl}}">
<div style="font-weight: 100;font-size: 17px;">{{game.name}}</div>
</div>
</ui-select-choices>
</ui-select>
<div style="display:flex">
<ui-select style="width: 100%" ng-model="$ctrl.selectedGame" required input-id="game" theme="bootstrap" spinner-enabled="true" on-select="$ctrl.gameSelected($item)">
<ui-select-match placeholder="Search for category...">
<div style="height: 25px; display:flex; flex-direction: row; align-items: center;">
<img style="height: 21px; width: 21px; border-radius: 5px; margin-right:5px;" ng-src="{{$select.selected.boxArtUrl}}">
<div style="font-weight: 100;font-size: 17px;">{{$select.selected.name}}</div>
</div>
</ui-select-match>
<ui-select-choices minimum-input-length="1" repeat="game in $ctrl.games | filter: $select.search" refresh="$ctrl.searchGames($select.search)" refresh-delay="200" style="position:relative;">
<div style="height: 35px; display:flex; flex-direction: row; align-items: center;">
<img style="height: 30px; width: 30px; border-radius: 5px; margin-right:10px;" ng-src="{{game.boxArtUrl}}">
<div style="font-weight: 100;font-size: 17px;">{{game.name}}</div>
</div>
</ui-select-choices>
</ui-select>
<div ng-show="$ctrl.selectedGame != null" style="margin-left: 3px">
<button
class="btn btn-default"
aria-label="Clear category"
uib-tooltip="Clear category"
ng-click="$ctrl.removeCategory()">
<i class="far fa-times"></i>
</button>
</div>
</div>
</div>
<div class="form-group" style="margin-bottom: 0;">
Expand Down Expand Up @@ -146,7 +157,7 @@
saveText: "Add",
inputPlaceholder: "Enter a tag",
validationFn: (value) => {
return new Promise(resolve => {
return new Promise((resolve) => {
// Must be alphanumeric no more than 25 characters
const tagRegExp = /^[a-z0-9]{1,25}$/ig;

Expand All @@ -170,7 +181,7 @@

$ctrl.searchGames = function(gameQuery) {
backendCommunicator.fireEventAsync("search-twitch-games", gameQuery)
.then(games => {
.then((games) => {
if (games != null) {
$ctrl.games = games;
}
Expand All @@ -184,6 +195,12 @@
}
};

$ctrl.removeCategory = function() {
$ctrl.selectedGame = null;
$ctrl.streamInfo.gameId = '';
$ctrl.streamInfo.gameName = null;
};

$ctrl.removeStreamTag = function(tag) {
$ctrl.streamInfo.tags = $ctrl.streamInfo.tags.filter(element => tag.toLowerCase() !== element.toLowerCase());
};
Expand Down

0 comments on commit cf1b9d1

Please sign in to comment.