From cf43a52713655112d0722d6d38ee6440247e0f7e Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Sat, 7 Dec 2024 19:36:56 +0300 Subject: [PATCH] fix(ajax): track set, photo commenting, reposts fixes #1170 --- Web/static/css/audios.css | 3 ++- Web/static/js/al_music.js | 39 ++++++++++++++++++++---------- Web/static/js/router.js | 1 + themepacks/midnight/stylesheet.css | 5 ++++ 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Web/static/css/audios.css b/Web/static/css/audios.css index b0a9e8ca..d3c7ba78 100644 --- a/Web/static/css/audios.css +++ b/Web/static/css/audios.css @@ -300,7 +300,8 @@ border-radius: inherit !important; } -.audioEntry.nowPlaying .performer a { +.audioEntry.nowPlaying .performer a, +.audioEntry.nowPlaying .performer { color: #f4f4f4 !important; } diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js index 68208c7d..94af455d 100644 --- a/Web/static/js/al_music.js +++ b/Web/static/js/al_music.js @@ -260,7 +260,7 @@ window.player = new class { } async setTrack(id, ref = null) { - if(!this.tracks || this.tracks.length < 1) { + if(!this.tracks/* || this.tracks.length < 1*/) { makeError('Context is not loaded yet', 'Red', 5000, 1489) return } @@ -287,7 +287,7 @@ window.player = new class { const c_track = this.currentTrack if(!c_track) { this.current_track_id = old_id - makeError('Error playing audio: track not found') + //makeError('Error playing audio: track not found') return } @@ -434,9 +434,9 @@ window.player = new class { async loadDump(dump_object) { this.context = dump_object.context - this.current_track_id = dump_object.current_track_id this.tracks = dump_object.tracks - if(this.current_track_id) { + if(dump_object.current_track_id && this.hasTrackWithId(dump_object.current_track_id)) { + this.current_track_id = dump_object.current_track_id await this.setTrack(this.current_track_id, 'localstorage') } @@ -519,10 +519,18 @@ window.player = new class { __findTrack(id, return_index = false) { if(return_index) { - return this.tracks.indexOf(this.tracks.find(item => item.id == id)) + try { + return this.tracks.indexOf(this.tracks.find(item => item.id == id)) + } catch(e) { + return -1 + } } - return this.tracks.find(item => item.id == id) + try { + return this.tracks.find(item => item.id == id) + } catch(e) { + return null + } } __findByIndex(index) { @@ -616,8 +624,10 @@ window.player = new class { } if(this.ajaxPlayer.length > 0) { - this.ajaxPlayer.find('#aj_player_track_title b').html(escapeHtml(_c.performer)) - this.ajaxPlayer.find('#aj_player_track_title span').html(escapeHtml(_c.name)) + if(_c) { + this.ajaxPlayer.find('#aj_player_track_title b').html(escapeHtml(_c.performer)) + this.ajaxPlayer.find('#aj_player_track_title span').html(escapeHtml(_c.name)) + } } u(`.tip_result`).remove() @@ -1113,6 +1123,9 @@ u(document).on("drop", '.audiosContainer', function(e) { e.dataTransfer.dropEffect = 'move' } else if(e.dataTransfer.types.length < 1 || e.dataTransfer.types.includes('text/uri-list')) { e.preventDefault() + if(window.player && !window.player.isAtCurrentContextPage()) { + return + } u('.audioEmbed.currently_dragging').removeClass('currently_dragging') const target = u(e.target).closest('.audioEmbed') @@ -1154,7 +1167,7 @@ u(document).on('contextmenu', '.bigPlayer, .audioEmbed, #ajax_audio_player', (e) ${tr('mute_tip_noun')} ` : ''} ${ctx_type == 'mini_player' ? ` - ${tr('audio_ctx_play_next')} + ` : ''} ${tr('audio_ctx_add_to_group')} ${tr('audio_ctx_add_to_playlist')} @@ -1567,7 +1580,7 @@ function __showAudioAddDialog(id, current_tab = 'club') { u('.entity_vertical_list').append(`
`) try { - window.openvk.writeableClubs = await API.Groups.getWriteableClubs() + window.openvk.writeableClubs = await window.OVKAPI.call('groups.get', {'filter': 'admin', 'count': 100}) } catch (e) { u("#_content").html(tr("no_access_clubs")) @@ -1577,7 +1590,7 @@ function __showAudioAddDialog(id, current_tab = 'club') { u('.entity_vertical_list #gif_loader').remove() } - window.openvk.writeableClubs.forEach(el => { + window.openvk.writeableClubs.items.forEach(el => { u("#_content .entity_vertical_list").append(`