-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Complete rework #32
base: master
Are you sure you want to change the base?
Conversation
chore: (FRONTEND): Adjusted logic for frontend with fetchStories, which allows to refresh data from backend.
BUILDED_ASSETS
feat: (STORIES): Create cache when insert data into database and sync them to all users on server.
feat: (LOCALES): Added missing locales. feat: (RESET_PED_RESOURCE_RESTART): Added reset state when resource is restarted. fix: (IS_REPORTER_VALIDATION): Added function to validate if user has job as reporter to allow him perform specific actions. chore: (STORIES_SORTING): Add sorting of recent stories by date, to show in proper order.
feat: (FRAMEWORK_API): Added basic framework bridge for ESX/QBCore feat: (INVENTORY_API): Added basic hook of ox_inventory / qb-inventories that can be used with the resource. feat: (INIT_DEBUG): Show on resource start relevant server/resource information. chore: (CONFIG): Added supported inventories, some variables, refactor
chore: (DEBUG) Improve print to be look better + added future todo for frontend timestamp / date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of comments. I'll re-review when updated/answered.
|
||
ui_page 'web/public/index.html' | ||
|
||
--[[ Resource Information ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a "github" property as well? The upcoming ps-core
can detect if the latest version is installed by this, and this might be added in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, what should be there? Let me know 👍
local jailTime = prisonerData and prisonerData.jailTime or 0 | ||
local prisonerName = prisonerData and prisonerData.name | ||
|
||
-- TODO: Requires to modify frontend with some variable with prefix jail format (seconds/mins/hours/days) to make proper sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something you need from me? ps-core
is going to come with utility functions for formatting dates, so we can use that if that was the intention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is now that is strictly to months in frontend when you see, related to create definition for locales of UI? 🤔
There is no problem to format it in backend, the thing why the note its there it will require refactor / adjustment in the frontend itself to make sense 👍
if player and data then | ||
if not IsReporter(playerId) then | ||
Framework.showNotify(playerId, l('NOT_ALLOWED'), 'error') | ||
return | ||
end | ||
|
||
local storyType = data.type and data.type:upper() | ||
|
||
if storyType then | ||
if STORIES_CACHE[storyType] then | ||
local id = #STORIES_CACHE[storyType] + 1 | ||
|
||
STORIES_CACHE[storyType][id] = { | ||
title = data.title, | ||
story_type = storyType, | ||
image = data.image, | ||
jailed_player = '', | ||
jailed_time = 0, | ||
id = id, | ||
publisher = player.charName, | ||
body = data.body, | ||
date = data.date, | ||
} | ||
|
||
table.sort(STORIES_CACHE[storyType], function(a, b) | ||
return a.date > b.date | ||
end) | ||
|
||
Database.PublishStory(data, player.charName) | ||
|
||
SyncStories(-1, STORIES_CACHE) | ||
|
||
Framework.showNotify(playerId, l('STORY_PUBLISHED'), 'success') | ||
else | ||
print('futte-newspaper:server:publishStory: storyType is not valid') | ||
end | ||
else | ||
print('futte-newspaper:server:publishStory: storyType is nil') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of it already has it, but could a couple of things be refactored to it has guardclauses instead? I think that would be more clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure we can improve this part + i will make 1 function which can handle this for the rest since we are using it for:
UPDATE, CREATE, DELETE 👍
RegisterNetEvent('futte-newspaper:server:deleteStory', function(data) | ||
local playerId = source | ||
local player = Framework.getPlayer(playerId) | ||
local storyId = data and data.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be a bit nit picky, but this variable name is not so representative of what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will come with better variable naming.
local itemState = Framework.DoesItemExist(Config.Items.NEWSPAPER) or 'UNK' | ||
local jobState = Framework.DoesJobExist(Config.Job.name) or 'UNK' | ||
|
||
sprint('\n^3%s^0\nVersion: ^3%s^0\nFramework: ^3%s^0\n^0Inventory: ^3%s\n^0\n^0Is required item [%s] registered: ^3%s^0\n^0Is required job [%s] registered in your FW: ^3%s\n^0', GetCurrentResourceName(), currentVersion, Config.Framework, Config.Inventory, Config.Items.NEWSPAPER, itemState and 'YES' or 'PLEASE DEFINE THE REQUIRED ITEM IN YOUR INVENTORY!', Config.Job.name, jobState and 'YES' or 'PLEASE DEFINE THE REQUIRED JOB IN YOUR FRAMEWORK!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be print
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will refactor this and define proper naming. 👍
const placeholderStory = { | ||
id: 0, | ||
title: 'Welcome to futte-newspaper', | ||
body: "<p>futte-newspaper is a standalone ressource for FiveM. It has the following dependencies:</p><p><ul><li>qb-target</li><li>oxmysql</li></ul></p><p>I hope you'll enjoy the resource. Feel free to open issues if you find a bug/wish new functionality. This story will automatically delete itself as soon as you write a new one.</p><p>- xFutte</p>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess it is not a standalone resource..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets keep it ESX/QBCORE, standalone version could be sorted out in future if needed really. 👍
chore: (JOB_STRUCTURE_NOTE): Removed leftover note for myself when i was working with framework job data.
chore: (getPlayer): Note for framework job data, removed it.
Description
This pull request focus on revamping/improving the backend logic overall, and adjusting the frontend to work perfectly with those changes.
State: WIP
TODO