8000 Refactor: remove hotwire by aidewoode · Pull Request #508 · blackcandy-org/blackcandy · GitHub
[go: up one dir, main page]

Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@
@import "./utilities/image.css";
@import "./utilities/cursor.css";
@import "./utilities/visibility.css";
@import "./utilities/bridge.css";
6 changes: 0 additions & 6 deletions app/assets/stylesheets/utilities/bridge.css

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/concerns/client_detection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ClientDetection
extend ActiveSupport::Concern

included do
helper_method :native_app?, :mobile?, :need_transcode?
helper_method :mobile?, :need_transcode?
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/dialog_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module DialogRendering
extend ActiveSupport::Concern

included do
layout -> { "dialog" if dialog? && !native_app? }
layout -> { "dialog" if dialog? }
helper_method :dialog?
before_action :remove_dialog_param_from_referer
before_action :render_dialog_frame
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def library_pages?

def page_title_tag(title)
title_suffix = " - #{t(:app_name)}"
title = "#{title}#{title_suffix unless native_app? || dialog?}"
title = "#{title}#{title_suffix unless dialog?}"

content_for(:title, title)
end
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/dialog_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ def self.verifier
end

def dialog_link_to(name, path, **options)
return link_to name, path, **options if native_app?

options[:data] = (options[:data] || {}).merge("turbo-frame" => "turbo-dialog", "turbo-action" => "advance")
link_to name, "?#{request.query_parameters.merge(DIALOG_PARAM => DialogHelper.verifier.generate(path)).to_query}", **options
end
Expand Down
9 changes: 0 additions & 9 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Idiomorph } from 'idiomorph'
import './controllers'

import Player from './player'
import { isNativeApp } from './helper'

window.App = {
player: new Player()
Expand All @@ -31,11 +30,3 @@ window.addEventListener('turbo:before-render', ({ detail }) => {
}
}
})

window.addEventListener('turbo:submit-start', (event) => {
// Disable form submission on native app when the form has data-disabled-on-native attribute.
if (event.target.dataset.disabledOnNative === 'true' && isNativeApp()) {
event.detail.formSubmission.stop()
event.stopPropagation()
}
}, { capture: true })
20 changes: 0 additions & 20 deletions app/javascript/controllers/bridge/account_controller.js

This file was deleted.

33 changes: 0 additions & 33 deletions app/javascript/controllers/bridge/album_controller.js

This file was deleted.

10 changes: 0 additions & 10 deletions app/javascript/controllers/bridge/flash_controller.js

This file was deleted.

33 changes: 0 additions & 33 deletions app/javascript/controllers/bridge/playlist_controller.js

This file was deleted.

17 changes: 0 additions & 17 deletions app/javascript/controllers/bridge/search_controller.js

This file was deleted.

47 changes: 0 additions & 47 deletions app/javascript/controllers/bridge/songs_controller.js

This file was deleted.

10 changes: 0 additions & 10 deletions app/javascript/controllers/bridge/theme_controller.js

This file was deleted.

5 changes: 0 additions & 5 deletions app/javascript/controllers/flash_controller.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Controller } from '@hotwired/stimulus'
import { isNativeApp } from '../helper'

export default class extends Controller {
static get shouldLoad () {
return !isNativeApp()
}

static values = {
timeout: { type: Number, default: 4000 }
}
Expand Down
21 changes: 0 additions & 21 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@

import { application } from "./application"

import Bridge__AccountController from "./bridge/account_controller"
application.register("bridge--account", Bridge__AccountController)

import Bridge__AlbumController from "./bridge/album_controller"
application.register("bridge--album", Bridge__AlbumController)

import Bridge__FlashController from "./bridge/flash_controller"
application.register("bridge--flash", Bridge__FlashController)

import Bridge__PlaylistController from "./bridge/playlist_controller"
application.register("bridge--playlist", Bridge__PlaylistController)

import Bridge__SearchController from "./bridge/search_controller"
application.register("bridge--search", Bridge__SearchController)

import Bridge__SongsController from "./bridge/songs_controller"
application.register("bridge--songs", Bridge__SongsController)

import Bridge__ThemeController from "./bridge/theme_controller"
application.register("bridge--theme", Bridge__ThemeController)

import CoverImageController from "./cover_image_controller"
application.register("cover-image", CoverImageController)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const installPlayingSongIndicator = (controller, getSongElements = () =>

const hidePlayingSong = () => {
const playingSongElement = getSongElements().find((element) => element.classList.contains('is-active'))
playingSongElement.classList.remove('is-active', 'is-paused')
playingSongElement?.classList.remove('is-active', 'is-paused')
}

const pausePlayingSong = () => {
Expand Down
5 changes: 0 additions & 5 deletions app/javascript/controllers/songs_controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Controller } from '@hotwired/stimulus'
import { installEventHandler } from './mixins/event_handler'
import { installPlayingSongIndicator } from './mixins/playing_song_indicator'
import { isNativeApp } from '../helper'

export default class extends Controller {
static get shouldLoad () {
return !isNativeApp()
}

static targets = ['item']

initialize () {
Expand Down
17 changes: 1 addition & 16 deletions app/javascript/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,9 @@ function dispatchEvent (element, type, data = null) {
element.dispatchEvent(new CustomEvent(type, { detail: data }))
}

function isiOSApp () {
return !!window.navigator.userAgent.match(/Black Candy iOS/)
}

function isAndroidApp () {
return !!window.navigator.userAgent.match(/Black Candy Android/)
}

function isNativeApp () {
return isiOSApp() || isAndroidApp()
}

export {
formatDuration,
randomIndex,
fetchRequest,
dispatchEvent,
isiOSApp,
isAndroidApp,
isNativeApp
dispatchEvent
}
6 changes: 2 additions & 4 deletions app/views/albums/_album.html.erb
10BC8
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
<%= link_to album_path(album) do %>
<%= cover_image_tag album, class: "c-cover" %>
<% end %>
<div class='c-card__image__actions' data-controller='bridge--album' data-bridge--album-id-value='<%= album.id %>'>
<div class='c-card__image__actions'>
<%= button_to(
current_playlist_album_path(album, should_play: true),
method: :put,
class: "c-button c-button--circle c-button--primary",
form: {
data: {
"disabled-on-native" => "true",
"turbo-frame" => "turbo-playlist",
"action" => "bridge--album#play"
"turbo-frame" => "turbo-playlist"
}
}
) do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/albums/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if filter_sort_presenter.has_filter? %>
<%= link_to albums_path, class: "c-button c-button--outline c-button--small u-mr-3", data: { "turbo-action" => ("replace" if native_app?) } do %>
<%= link_to albums_path, class: "c-button c-button--outline c-button--small u-mr-3" do %>
<span class='o-flex o-flex--align-center'>
<%= icon_tag "close" %>
<%= t("label.clear_filters") %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/albums/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% page_title_tag t("label.edit_album") %>

<%= form_with model: @album, data: { "turbo-frame" => "_top", "turbo-action" => ("replace" if native_app?) }, class: "c-form" do |form| %>
<%= form_with model: @album, data: { "turbo-frame" => "_top" }, class: "c-form" do |form| %>
<div class='c-form__field'>
<%= form.label :cover_image, t("field.album_cover") %>
<%= form.file_field :cover_image, accept: "image/png, image/jpeg", class: "c-input" %>
Expand Down
Loading
Loading
0