mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 02:46:16 -08:00
feat(playlist): add SQLite integration for playlist management in Tauri
This commit is contained in:
1 parent
744a63f327
commit
6b52d6b059
2 files changed
+42
-5
No files matched your search
@@ -5,6 +5,8 @@ import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { StorageMap } from '@ngx-pwa/local-storage';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { isTauri } from '@tauri-apps/api/core';
|
||||
import Database from '@tauri-apps/plugin-sql';
|
||||
import {
|
||||
combineLatestWith,
|
||||
firstValueFrom,
|
||||
@@ -19,6 +21,7 @@ import {
|
||||
OPEN_MPV_PLAYER,
|
||||
OPEN_VLC_PLAYER,
|
||||
} from '../../../shared/ipc-commands';
|
||||
import { Playlist } from '../../../shared/playlist.interface';
|
||||
import { DataService } from '../services/data.service';
|
||||
import { PlaylistsService } from '../services/playlists.service';
|
||||
import { Settings, VideoPlayer } from '../settings/settings.interface';
|
||||
@@ -222,14 +225,34 @@ export class PlaylistEffects {
|
||||
switchMap((action) =>
|
||||
this.playlistsService.addPlaylist(action.playlist)
|
||||
),
|
||||
tap((playlist) => {
|
||||
if (playlist.serverUrl) {
|
||||
map((playlist: Playlist) => {
|
||||
if (playlist.serverUrl && !isTauri()) {
|
||||
this.router.navigate(['/xtreams/', playlist._id]);
|
||||
} else if (playlist.macAddress) {
|
||||
this.router.navigate(['portals', playlist._id]);
|
||||
} else {
|
||||
this.router.navigate(['/playlists/', playlist._id]);
|
||||
}
|
||||
return playlist;
|
||||
}),
|
||||
map(async (playlist) => {
|
||||
if (playlist.serverUrl && isTauri()) {
|
||||
const db = await Database.load('sqlite:database.db');
|
||||
const result = await db.execute(
|
||||
`INSERT INTO playlists (id, name, serverUrl, username, password, type)
|
||||
VALUES (?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
playlist._id.toString(),
|
||||
playlist.title || '',
|
||||
playlist.serverUrl || '',
|
||||
playlist.username || '',
|
||||
playlist.password || '',
|
||||
'xtream',
|
||||
]
|
||||
);
|
||||
console.log('inserted item', result);
|
||||
this.router.navigate(['/xtreams/', playlist._id]);
|
||||
}
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -240,9 +263,13 @@ export class PlaylistEffects {
|
||||
() => {
|
||||
return this.actions$.pipe(
|
||||
ofType(PlaylistActions.updatePlaylistMeta),
|
||||
switchMap((action) =>
|
||||
this.playlistsService.updatePlaylistMeta(action.playlist)
|
||||
)
|
||||
switchMap((action) => {
|
||||
// TODO update playlist in sqlite db
|
||||
|
||||
return this.playlistsService.updatePlaylistMeta(
|
||||
action.playlist
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
{ dispatch: false }
|
||||
|
||||
@@ -101,6 +101,16 @@ export const selectCurrentPlaylist = createSelector(
|
||||
}
|
||||
);
|
||||
|
||||
export const selectActivePlaylist = createSelector(
|
||||
selectPlaylistsMetaState,
|
||||
(state) => {
|
||||
if (state.entities && state.selectedId !== '') {
|
||||
return state.entities[state.selectedId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
export const selectFavorites = createSelector(
|
||||
selectPlaylistsMetaState,
|
||||
fromPlaylistMetaState.getPlaylistMetaEntities,
|
||||
|
||||
Reference in new issue
Block a user