diff --git a/docker/prod/deploy.sh b/docker/prod/deploy.sh index 3b7ee1740..2e8728180 100755 --- a/docker/prod/deploy.sh +++ b/docker/prod/deploy.sh @@ -12,8 +12,6 @@ third_semver=$(echo $new_tag | cut -d "." -f 3) # Setting the version on the front end cd ../../ -echo "export const version: string = '$new_tag';" > "ui/src/version.ts" -git add "ui/src/version.ts" # Setting the version on the backend echo "pub const VERSION: &str = \"$new_tag\";" > "server/src/version.rs" git add "server/src/version.rs" diff --git a/docs/src/contributing_websocket_http_api.md b/docs/src/contributing_websocket_http_api.md index 5af89431a..7aab35782 100644 --- a/docs/src/contributing_websocket_http_api.md +++ b/docs/src/contributing_websocket_http_api.md @@ -754,6 +754,8 @@ Search types are `All, Comments, Posts, Communities, Users, Url` site: Option, admins: Vec, banned: Vec, + online: usize, // This is currently broken + version: String, } } ``` diff --git a/server/src/api/site.rs b/server/src/api/site.rs index 241a80e31..a945d9ec0 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -3,6 +3,7 @@ use crate::{ api::{claims::Claims, APIError, Oper, Perform}, apub::fetcher::search_by_apub_id, blocking, + version, websocket::{server::SendAllMessage, UserOperation, WebsocketInfo}, DbPool, LemmyError, @@ -110,6 +111,7 @@ pub struct GetSiteResponse { admins: Vec, banned: Vec, pub online: usize, + version: String, } #[derive(Serialize, Deserialize)] @@ -424,6 +426,7 @@ impl Perform for Oper { admins, banned, online, + version: version::VERSION.to_string(), }) } } @@ -666,6 +669,7 @@ impl Perform for Oper { admins, banned, online: 0, + version: version::VERSION.to_string(), }) } } diff --git a/ui/src/components/admin-settings.tsx b/ui/src/components/admin-settings.tsx index 0034c229e..6fe4e9347 100644 --- a/ui/src/components/admin-settings.tsx +++ b/ui/src/components/admin-settings.tsx @@ -46,6 +46,7 @@ export class AdminSettings extends Component { admins: [], banned: [], online: null, + version: null, }, siteConfigForm: { config_hjson: null, diff --git a/ui/src/components/footer.tsx b/ui/src/components/footer.tsx index cadb6aa39..e911370fa 100644 --- a/ui/src/components/footer.tsx +++ b/ui/src/components/footer.tsx @@ -1,12 +1,41 @@ import { Component } from 'inferno'; import { Link } from 'inferno-router'; -import { repoUrl } from '../utils'; -import { version } from '../version'; import { i18n } from '../i18next'; +import { Subscription } from 'rxjs'; +import { retryWhen, delay, take } from 'rxjs/operators'; +import { WebSocketService } from '../services'; +import { repoUrl, wsJsonToRes } from '../utils'; +import { + UserOperation, + WebSocketJsonResponse, + GetSiteResponse, +} from '../interfaces'; -export class Footer extends Component { +interface FooterState { + version: string; +} + +export class Footer extends Component { + private wsSub: Subscription; + emptyState: FooterState = { + version: null, + }; constructor(props: any, context: any) { super(props, context); + + this.state = this.emptyState; + + this.wsSub = WebSocketService.Instance.subject + .pipe(retryWhen(errors => errors.pipe(delay(3000), take(10)))) + .subscribe( + msg => this.parseMessage(msg), + err => console.error(err), + () => console.log('complete') + ); + } + + componentWillUnmount() { + this.wsSub.unsubscribe(); } render() { @@ -15,7 +44,7 @@ export class Footer extends Component {