Compare commits

...
2 Commits
Author SHA1 Message Date
death-claw d5ae5d57d1 v3.0.4 2020-08-16 16:11:11 +01:00
death-claw 537d76d7be Improve rename UI 2020-08-16 16:06:17 +01:00
20 changed files with 62 additions and 32 deletions
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [3.0.4] - 2020-08-16
### Changed
- Improve rename UI
## [3.0.3] - 2020-08-16
### Changed
- Fix bugs with electron app
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-electron",
"version": "3.0.3",
"version": "3.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-electron",
"version": "3.0.3",
"version": "3.0.4",
"description": "A ripper for vipergirls.to built using web technolgies",
"main": "main.js",
"author": "death-claw <53543762+death-claw@users.noreply.github.com>",
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
</parent>
<artifactId>vripper-electron</artifactId>
<name>vripper-electron</name>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
</parent>
<artifactId>vripper-server</artifactId>
<name>vripper-server</name>
@@ -52,6 +52,8 @@ public class Post {
private Metadata metadata;
private boolean renaming;
public Post(String title, String url, String postId, String threadId, String threadTitle, String forum, String securityToken) {
this.title = title;
this.url = url;
@@ -253,4 +253,8 @@ public class DataService {
postRepository.updateThanked(thanked, id);
livePostsState.onNext(id);
}
public void refreshPost(Long id) {
livePostsState.onNext(id);
}
}
@@ -1,5 +1,6 @@
package tn.mnlr.vripper.services;
import lombok.Getter;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,10 +12,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@@ -28,6 +26,9 @@ public class PathService {
private final CommonExecutor commonExecutor;
@Getter
private final Set<String> renaming = Collections.synchronizedSet(new HashSet<>());
@Autowired
public PathService(AppSettingsService appSettingsService, DataService dataService, MutexService mutexService, CommonExecutor commonExecutor) {
this.appSettingsService = appSettingsService;
@@ -54,19 +55,16 @@ public class PathService {
}
public final void rename(@NonNull String postId, @NonNull String altName) {
renaming.add(postId);
Post post = dataService.findPostByPostId(postId).orElseThrow();
dataService.refreshPost(post.getId());
commonExecutor.getGeneralExecutor().submit(() -> {
ReentrantLock postLock = mutexService.getPostLock(postId);
if (postLock != null) {
postLock.lock();
}
ReentrantLock postLock = null;
try {
Optional<Post> _post = dataService.findPostByPostId(postId);
if (_post.isEmpty()) {
return;
postLock = mutexService.getPostLock(postId);
if (postLock != null) {
postLock.lock();
}
Post post = _post.get();
if (altName.equals(post.getTitle())) {
return;
}
@@ -100,6 +98,9 @@ public class PathService {
log.warn(String.format("Failed to remove %s", currentDesFolder.toString()));
}
} finally {
renaming.remove(postId);
dataService.refreshPost(post.getId());
if (postLock != null) {
postLock.unlock();
}
@@ -22,13 +22,15 @@ public class AppDataController {
private final GlobalStateService globalStateService;
private final DownloadSpeedService downloadSpeedService;
private final DataService dataService;
private final PathService pathService;
@Autowired
public AppDataController(VipergirlsAuthService vipergirlsAuthService, GlobalStateService globalStateService, DownloadSpeedService downloadSpeedService, DataService dataService) {
public AppDataController(VipergirlsAuthService vipergirlsAuthService, GlobalStateService globalStateService, DownloadSpeedService downloadSpeedService, DataService dataService, PathService pathService) {
this.vipergirlsAuthService = vipergirlsAuthService;
this.globalStateService = globalStateService;
this.downloadSpeedService = downloadSpeedService;
this.dataService = dataService;
this.pathService = pathService;
}
@Getter
@@ -58,7 +60,7 @@ public class AppDataController {
@SubscribeMapping("/posts")
public Collection<Post> posts() {
return StreamSupport.stream(dataService.findAllPosts().spliterator(), false).collect(Collectors.toList());
return StreamSupport.stream(dataService.findAllPosts().spliterator(), false).peek(this::isRenaming).collect(Collectors.toList());
}
@SubscribeMapping("/images/{postId}")
@@ -70,4 +72,10 @@ public class AppDataController {
public Collection<Queued> queued() {
return StreamSupport.stream(dataService.findAllQueued().spliterator(), false).collect(Collectors.toList());
}
private void isRenaming(Post post) {
if (pathService.getRenaming().contains(post.getPostId())) {
post.setRenaming(true);
}
}
}
@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;
import tn.mnlr.vripper.jpa.domain.Image;
import tn.mnlr.vripper.jpa.domain.Post;
import tn.mnlr.vripper.services.*;
import javax.annotation.PostConstruct;
@@ -27,16 +28,18 @@ public class WebSocketBroadcast {
private final GlobalStateService globalStateService;
private final DownloadSpeedService downloadSpeedService;
private final DataService dataService;
private final PathService pathService;
private final List<Disposable> disposables = new ArrayList<>();
@Autowired
public WebSocketBroadcast(SimpMessagingTemplate template, VipergirlsAuthService vipergirlsAuthService, GlobalStateService globalStateService, DownloadSpeedService downloadSpeedService, DataService dataService) {
public WebSocketBroadcast(SimpMessagingTemplate template, VipergirlsAuthService vipergirlsAuthService, GlobalStateService globalStateService, DownloadSpeedService downloadSpeedService, DataService dataService, PathService pathService) {
this.template = template;
this.vipergirlsAuthService = vipergirlsAuthService;
this.globalStateService = globalStateService;
this.downloadSpeedService = downloadSpeedService;
this.dataService = dataService;
this.pathService = pathService;
}
@PostConstruct
@@ -63,7 +66,7 @@ public class WebSocketBroadcast {
.buffer(500, TimeUnit.MILLISECONDS)
.map(HashSet::new)
.filter(e -> !e.isEmpty())
.subscribe(ids -> template.convertAndSend("/topic/posts", ids.stream().map(dataService::findPostById).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList())), e -> log.error("Failed to send data to client", e)));
.subscribe(ids -> template.convertAndSend("/topic/posts", ids.stream().map(dataService::findPostById).filter(Optional::isPresent).map(Optional::get).peek(this::isRenaming).collect(Collectors.toList())), e -> log.error("Failed to send data to client", e)));
disposables.add(dataService.liveImage()
.subscribeOn(Schedulers.io())
@@ -105,6 +108,12 @@ public class WebSocketBroadcast {
);
}
private void isRenaming(Post post) {
if (pathService.getRenaming().contains(post.getPostId())) {
post.setRenaming(true);
}
}
@PreDestroy
private void destroy() {
disposables.forEach(Disposable::dispose);
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-ui",
"version": "3.0.3",
"version": "3.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-ui",
"version": "3.0.3",
"version": "3.0.4",
"scripts": {
"ng": "ng",
"start": "ng serve",
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>3.0.3</version>
<version>3.0.4</version>
</parent>
<artifactId>vripper-ui</artifactId>
<name>vripper-ui</name>
@@ -11,7 +11,8 @@ export class PostState {
public hosts: string[],
public thanked: boolean,
public previews: string[],
public metadata: Metadata
public metadata: Metadata,
public renaming: boolean
) {
}
}
@@ -24,7 +24,7 @@
<mat-icon class="icon" fxFlex="none" color="primary" [appPreview]="postState.previews">image</mat-icon>
<span class="title">
<p [title]="postState.title">{{
postState.title
postState.renaming ? 'Renaming gallery...' : postState.title
}}</p>
<p><label>Alternative titles: </label><span
[title]="postState.metadata?.resolvedNames?.join(', ')">{{postState.metadata?.resolvedNames?.join(', ') || 'none'}}</span></p>
@@ -103,7 +103,7 @@
</section>
</form>
</mat-tab>
<mat-tab label="Desktop Integration">
<mat-tab label="Desktop Integration" *ngIf="electronService.isElectronApp">
<form [formGroup]="desktopSettingsForm" autocomplete="off">
<mat-checkbox *ngIf="electronService.isElectronApp" color="primary" formControlName="desktopClipboard"
name="desktopClipboard"
+2 -1
View File
@@ -139,7 +139,8 @@ export class WsConnectionService {
element.hosts,
element.thanked,
element.previews,
element.metadata
element.metadata,
element.renaming
)
);
});
@@ -2,5 +2,5 @@ export const environment = {
production: true,
localhost: `${window.location.protocol}//${window.location.host}`,
ws: `${window.location.protocol === 'http:' ? 'ws:' : 'wss:'}//${window.location.host}`,
version: '3.0.3'
version: '3.0.4'
};
+1 -1
View File
@@ -6,7 +6,7 @@ export const environment = {
production: false,
localhost: 'http://localhost:8080',
ws: 'ws://localhost:8080',
version: '3.0.3'
version: '3.0.4'
};
/*